• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# RAIN类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中RAIN的典型用法代码示例。如果您正苦于以下问题:C# RAIN类的具体用法?C# RAIN怎么用?C# RAIN使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RAIN类属于命名空间,在下文中一共展示了RAIN类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Execute

    public override ActionResult Execute(RAIN.Core.AI ai)
    {
        Animator animator = ai.Body.GetComponent<Animator>();
        animator.SetBool("run", true);

        NavMeshAgent myAgent = ai.Body.GetComponent<NavMeshAgent>();
        Vector3 myDestiny = ai.WorkingMemory.GetItem<Vector3>("destination");
        Vector3 myPos = ai.Body.transform.position;

        float distance = Vector3.Distance(myPos, myDestiny);
        float myRadius = ai.Body.GetComponent<CapsuleCollider>().radius;

        //Debug.Log ("distance" + distance);
        //Debug.Log ("my rad" + myRadius);
        //Debug.Log ("-------------------------------------");

        //if the cop has reached his destination, search for a bit
        if(distance < 1 ){
            ai.WorkingMemory.SetItem<bool>("isSearching", true);
            //ai.WorkingMemory.SetItem<bool>("hasDestination", false);
            //Debug.Log ("MOVE ON TO SEARCHING");
            return ActionResult.SUCCESS;
        }

        return ActionResult.RUNNING;
    }
开发者ID:sabrinagreenlee,项目名称:JaneBound,代码行数:26,代码来源:Navigate.cs


示例2: Execute

 public override ActionResult Execute(RAIN.Core.AI ai)
 {
     ai.Motor.Stop ();
     VariableManager.StartInteractingWithPlayer (ai);
     //Vector3 targetPosition = ai.WorkingMemory.GetItem<Vector3>("player") - ai.Body.transform.forward;
     return ActionResult.SUCCESS;
 }
开发者ID:guozanhua,项目名称:fantastic_m2,代码行数:7,代码来源:StartInteractingWithObject.cs


示例3: Execute

 public override ActionResult Execute(RAIN.Core.AI ai)
 {
     _Time = _Time + Time.deltaTime;
     float phase = Mathf.Sin(_Time / _Period);
     ai.Kinematic.Rotation = new Vector3(0, phase * _Angle, 0);
     return ActionResult.SUCCESS;
 }
开发者ID:sabrinagreenlee,项目名称:JaneBound,代码行数:7,代码来源:Scan.cs


示例4: Execute

 public override ActionResult Execute(RAIN.Core.AI ai)
 {
     NPC npc=  ai.Body.GetComponent<NPC>();
     npc.AnimRange=NPC.AI_ANIM_ATTACK_BASH;
     //gob.executeAttack();
     return ActionResult.SUCCESS;
 }
开发者ID:hankmorgan,项目名称:UnderworldExporter,代码行数:7,代码来源:AI_ATTACK_BASH.cs


示例5: Execute

    public override ActionResult Execute(RAIN.Core.AI ai)
    {
        if (!targetObject)
            return ActionResult.FAILURE;

        //Resource 를 Target 에 전달
        GameObject agent = ai.Body;
        Component cpnt = agent.GetComponent<CInventory>();

        if (cpnt)
        {
            ArrayList item = ((CInventory)cpnt).PopItem("Resource");

            cpnt = targetObject.GetComponent<CInventory>();
            if (cpnt)
            {
                ((CInventory)cpnt).AddItem("Resource", item);
            }
        }
        else
        {
            return ActionResult.FAILURE;
        }

        return ActionResult.SUCCESS;
    }
开发者ID:Overseer66,项目名称:Survival-Simulation,代码行数:26,代码来源:RASaveResource.cs


示例6: Start

 public override void Start(RAIN.Core.AI ai)
 {
     R = Random.Range (0.0f, 1.0f);
     G = Random.Range (0.0f, 1.0f);
     B = Random.Range (0.0f, 1.0f);
     base.Start(ai);
 }
开发者ID:NunezG,项目名称:villeEmergente,代码行数:7,代码来源:colorChange.cs


示例7: Execute

 public override ActionResult Execute(RAIN.Core.AI ai)
 {
     //ai.WorkingMemory.GetItem<Vector3>("moveStartPoint");
     ai.WorkingMemory.SetItem<Vector3>("MoveTarget",ai.WorkingMemory.GetItem<Vector3>("moveStartPoint"));
     //ai.WorkingMemory.SetItem<bool>("isMovingRandom",false);
     return ActionResult.SUCCESS;
 }
开发者ID:hankmorgan,项目名称:UnderworldExporter,代码行数:7,代码来源:AI_STOP_MOVE.cs


示例8: Execute

    public override ActionResult Execute(RAIN.Core.AI ai)
    {
        GameObject agent = ai.Body;
        Vector2 target = ai.WorkingMemory.GetItem<Vector2>("WanderTarget");
        Vector2 position = agent.transform.position;

        if (position != beforePos)
        {
            return ActionResult.FAILURE;
        }

        Vector2 move = (target - position).normalized * moveSpeed * ai.DeltaTime;
        agent.transform.Translate(move);                
        ai.Motor.UpdateMotionTransforms();
        beforePos = agent.transform.position;
        
        if ( (position - target).magnitude < 0.1f)
        {
            return ActionResult.SUCCESS;
        }
        else
        {
            return ActionResult.RUNNING;
        }
    }
开发者ID:Overseer66,项目名称:Survival-Simulation,代码行数:25,代码来源:RAMoveToPosition.cs


示例9: Start

    public override void Start(RAIN.Core.AI ai)
    {
        base.Start(ai);

        _lastRunning = 0;
        m_TurretController = ai.Body.GetComponent<TurretController>();
    }
开发者ID:bendova,项目名称:Tanks,代码行数:7,代码来源:NeedsAmmo.cs


示例10: Start

 public override void Start(RAIN.Core.AI ai)
 {
     base.Start(ai);
     m_Angle = 0.0f;
     m_TurretController = ai.Body.GetComponent<TurretController>();
     m_Turret = m_TurretController.m_ShellSpawner.transform.parent.gameObject;
 }
开发者ID:bendova,项目名称:Tanks,代码行数:7,代码来源:LookAround.cs


示例11: Execute

    public override ActionResult Execute(RAIN.Core.AI ai)
    {
        _allMatches = suspects.Evaluate<IList<RAIN.Entities.Aspects.RAINAspect>>(ai.DeltaTime, ai.WorkingMemory);
        if (_allMatches == null || _hellephant == null)
        {
            ai.WorkingMemory.SetItem<GameObject>(boyObject.VariableName, null);
            return ActionResult.FAILURE;
        }
        AIRig attackedAI = _hellephant.GetComponentInChildren<AIRig>();
        _attacker = attackedAI.AI.WorkingMemory.GetItem<GameObject>("attacker");

        GameObject result = null;
        Debug.Log("isIn:\n\tCount: " + _allMatches.Count);
        foreach (RAIN.Entities.Aspects.RAINAspect aspect in _allMatches)
        {
            Debug.Log("isIn:\n\tTAG: " + aspect.Entity.Form.tag);
            if (aspect.Entity.Form.GetInstanceID() == _attacker.GetInstanceID())
            {
                result = _attacker;
                break;
            }
        }
        ai.WorkingMemory.SetItem<GameObject>(boyObject.VariableName, result);
        return ActionResult.SUCCESS;
    }
开发者ID:FerranPares,项目名称:NDVW-1,代码行数:25,代码来源:isIn.cs


示例12: Execute

 public override ActionResult Execute(RAIN.Core.AI ai)
 {
     if( ai.Body.GetComponent<Passant>().sceneLeader.GetComponent<Musicien>()!=null)
         return ActionResult.SUCCESS;
     else
         return ActionResult.FAILURE;
 }
开发者ID:NunezG,项目名称:villeEmergente,代码行数:7,代码来源:IfMusicien.cs


示例13: Start

 public override void Start(RAIN.Core.AI ai)
 {
     //Change the FOV Color
     FOV2DVisionCone FOV = ai.Body.transform.Find("FOV2D").GetComponent<FOV2DVisionCone>();
     FOV.status = FOV2DVisionCone.Status.Idle;
     base.Start(ai);
 }
开发者ID:sabrinagreenlee,项目名称:JaneBound,代码行数:7,代码来源:FOVColorChange.cs


示例14: Execute

    public override ActionResult Execute(RAIN.Core.AI ai)
    {
        RAINSensor sensor = ai.Senses.GetSensor("AttackRangeSensor");

        Vector3 targetPos = TargetPos.Evaluate<Vector3>(ai.DeltaTime, ai.WorkingMemory);
        float speed = MoveSpeed.Evaluate<float>(ai.DeltaTime, ai.WorkingMemory);
        float range = Range.Evaluate<float>(ai.DeltaTime, ai.WorkingMemory);

        float distanceToTarget = Vector3.Distance(ai.Body.transform.position, targetPos);
        if (distanceToTarget > range)
        {
            Vector3 dirToTarget = targetPos - ai.Body.transform.position;
            dirToTarget *= range/dirToTarget.magnitude;
            ai.Motor.Speed = speed;
            ai.Motor.MoveTo(ai.Body.transform.position + dirToTarget);
            m_TurretController.TurnTurretForward();
        }
        else
        {
            targetPos.y = m_TurretController.Turret.transform.position.y;
            m_TurretController.TurretLookAt(targetPos);
        }

        return ActionResult.SUCCESS;
    }
开发者ID:bendova,项目名称:Tanks,代码行数:25,代码来源:KeepTargetInRange.cs


示例15: Execute

    public override RAIN.Action.Action.ActionResult Execute(RAIN.Core.Agent agent, float deltaTime)
    {
        SetVariables(agent);
        if(isPlayer == 1)
            return RAIN.Action.Action.ActionResult.SUCCESS;
        /*if(unit == null)
            unit = agent.Avatar.GetComponent<Unit>();
        Unit nearestEnemy = unit.DetectEnemies(agent,enemy);
        if(nearestEnemy != null)
        {
            unit.Shoot(agent,deltaTime,nearestEnemy);
        }

        if(orders == Order.stop)
        {
            agent.MoveTo(agent.Avatar.transform.position,deltaTime);
            return RAIN.Action.Action.ActionResult.FAILURE;
        }*/
        /*Transform target = unit.GetMoveTarget();
        if(target != null)
        {

            //agent.MoveTo(agent.Avatar.transform.position,deltaTime);
            //return RAIN.Action.Action.ActionResult.FAILURE;
        }*/
        //if(agent.MoveTo(target.position,deltaTime))
            return RAIN.Action.Action.ActionResult.SUCCESS;
        //return RAIN.Action.Action.ActionResult.RUNNING;
    }
开发者ID:Jay2645,项目名称:ludum-dare-7dRTS,代码行数:29,代码来源:UnitCheckOrders.cs


示例16: Execute

 public override ActionResult Execute(RAIN.Core.AI ai)
 {
     if (ai.WorkingMemory.GetItem<GameObject>("target") != null)
         return ActionResult.SUCCESS;
     else
         return ActionResult.FAILURE;
 }
开发者ID:NunezG,项目名称:villeEmergente,代码行数:7,代码来源:IfHasTarget.cs


示例17: Execute

 // Action RAIN pour faire appel à la fonction correspondante du passant
 public override ActionResult Execute(RAIN.Core.AI ai)
 {
     ai.Body.GetComponent<Passant>().SelectAndEnterScene();
     ai.WorkingMemory.SetItem<bool>("destinationReached", true);// si le passant entre dans une scène on considère qu'il a atteint sa destination
     ai.WorkingMemory.SetItem<bool>("moving", false); // booléen moving utilisé pour les mouvements hors scene
     return ActionResult.SUCCESS;
 }
开发者ID:NunezG,项目名称:villeEmergente,代码行数:8,代码来源:PassantSelectAndEnterScene.cs


示例18: Execute

 public override ActionResult Execute(RAIN.Core.AI ai)
 {
     if ((Physics2D.Raycast(origen_up_left, new Vector2(0, distancia), distancia) ||
         Physics2D.Raycast(origen_up_right, new Vector2(0, distancia), distancia)) &&
         ai.WorkingMemory.GetItem<string>("direccion") != "down")
     {
         return ActionResult.SUCCESS;
     }
     else if ((Physics2D.Raycast(origen_down_left, new Vector2(0, -distancia), distancia) ||
             Physics2D.Raycast(origen_down_right, new Vector2(0, -distancia), distancia)) &&
             ai.WorkingMemory.GetItem<string>("direccion") != "up")
     {
         return ActionResult.SUCCESS;
     }
     else if ((Physics2D.Raycast(origen_right_up, new Vector2(distancia, 0), distancia) ||
             Physics2D.Raycast(origen_right_down, new Vector2(distancia, 0), distancia)) &&
             ai.WorkingMemory.GetItem<string>("direccion") != "left")
     {
         return ActionResult.SUCCESS;
     }
     else if ((Physics2D.Raycast(origen_left_up, new Vector2(-distancia, 0), distancia) ||
             Physics2D.Raycast(origen_left_down, new Vector2(-distancia, 0), distancia)) &&
             ai.WorkingMemory.GetItem<string>("direccion") != "right")
     {
         return ActionResult.SUCCESS;
     }
     else
     {
         return ActionResult.FAILURE;
     }
 }
开发者ID:MauricioMCavalleriS,项目名称:light_cycles,代码行数:31,代码来源:Comprobar_muros.cs


示例19: Execute

    public override ActionResult Execute(RAIN.Core.AI ai)
    {
        if (!WanderTargetVariable.IsVariable)
            throw new Exception("The Choose Wander Position node requires a valid Wander Target Variable");

        float tWanderDistance = 0f;
        if (WanderDistance.IsValid)
            tWanderDistance = WanderDistance.Evaluate<float>(ai.DeltaTime, ai.WorkingMemory);

        if (tWanderDistance <= 0f)
            tWanderDistance = _defaultWanderDistance;

        Vector3 tDirection = new Vector3(UnityEngine.Random.Range(-1f, 1f), 0f, UnityEngine.Random.Range(-1f, 1f));
        tDirection *= tWanderDistance;

        Vector3 tDestination = ai.Kinematic.Position + tDirection;
        if (StayOnGraph.IsValid && (StayOnGraph.Evaluate<bool>(ai.DeltaTime, ai.WorkingMemory)))
        {
            if (NavigationManager.Instance.GraphForPoint(tDestination, ai.Motor.MaxHeightOffset, NavigationManager.GraphType.Navmesh, ((BasicNavigator)ai.Navigator).GraphTags).Count == 0)
                return ActionResult.FAILURE;
        }

        ai.WorkingMemory.SetItem<Vector3>(WanderTargetVariable.VariableName, tDestination);

        return ActionResult.SUCCESS;
    }
开发者ID:jdohgamer,项目名称:SSC,代码行数:26,代码来源:ChooseWanderPosition.cs


示例20: Execute

    public override ActionResult Execute(RAIN.Core.AI ai)
    {
        //Debug.Log ("SELECTTARG");
        if (target == null) {
            //Debut de la partie
            int targetIndex = Random.Range (0, ai.Body.GetComponent<Musicien>().targets.Count );
            Debug.Log(ai.Body.name + " : targetIndex : " + targetIndex);
            target = ai.Body.GetComponent<Musicien>().targets [targetIndex];

        } else {
            //pourcentage pour retour au target précédent
            float percent = Random.Range(0,100);

            //choix random du target suivant
            int targetIndex = Random.Range (0, target.GetComponent<navigationScript>().targets.Count );

            //si le target choisi est le précédent, on a un 75% de probabilités de recommencer cette action
            if (ai.Body.GetComponent<Musicien>().previousTarget == target.GetComponent<navigationScript>().targets[targetIndex] &&  percent < 75)
                return ActionResult.RUNNING;

            //set le target précédent
            ai.Body.GetComponent<Musicien>().previousTarget = target;

            //set le target actuel
            target = target.GetComponent<navigationScript>().targets [targetIndex];
        }
        ai.WorkingMemory.SetItem<bool>("destinationReached", false);
        return ActionResult.SUCCESS;
    }
开发者ID:NunezG,项目名称:villeEmergente,代码行数:29,代码来源:ProtoSelectTarget.cs



注:本文中的RAIN类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# RC类代码示例发布时间:2022-05-24
下一篇:
C# Quote类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap