Exemplo n.º 1
0
 private void InitActions(AIStateController controller)
 {
     foreach (AIAction action in actions)
     {
         action.Init(controller);
     }
 }
Exemplo n.º 2
0
 private void OnCollisionActions(AIStateController controller, Collision collision, AIStateController.CollisionType collisionType)
 {
     foreach (AIAction action in actions)
     {
         action.OnCollision(controller, collision, collisionType);
     }
 }
Exemplo n.º 3
0
 protected void OnTriggerActions(AIStateController controller, Collider other, AIStateController.TriggerType triggerType)
 {
     foreach (AIAction action in actions)
     {
         action.OnTrigger(controller, other, triggerType);
     }
 }
Exemplo n.º 4
0
 private void InitTransitions(AIStateController controller)
 {
     foreach (AIStateTransition transition in transitions)
     {
         transition.Init(controller);
     }
 }
Exemplo n.º 5
0
 private void ResumeActions(AIStateController controller)
 {
     foreach (AIAction action in actions)
     {
         action.Resume(controller);
     }
 }
Exemplo n.º 6
0
 private void DisposeActions(AIStateController controller)
 {
     foreach (AIAction action in actions)
     {
         action.Dispose(controller);
     }
 }
Exemplo n.º 7
0
Arquivo: Ball.cs Projeto: hnjog/ArPets
    // 작동 될 때
    private void OnEnable()
    {
        if (b_rigid == null)
        {
            transform.SetParent(null);                                          // 부모를 없애어, 플레이어의 시각으로부터 자유로워진다.
            b_rigid = GetComponent <Rigidbody>();
            //tf = GameObject.Find("LookChecker");
            //tf.transform.SetParent(null);                           // 부모를 없애어, 플레이어가 어디를 보고 치던 벨루가에게 날아가도록 한다.
            //player = GameObject.Find("Camera Container");
            veluga  = GameObject.Find("BelugaAxis");
            aiState = GameObject.Find("BelugaAxis").GetComponent <AIStateController>();
            input   = GameObject.Find("Main Camera").GetComponent <UInput>();
            caTF    = GameObject.Find("Main Camera").GetComponent <Transform>();
            //catchTF = GameObject.Find("CatchPoint");
            ballHit = GameObject.Find("Particle").transform.Find("Ball");
        }

        // off 한 후의 힘 초기화
        b_rigid.velocity = Vector3.zero;
        BallVelo         = Throwing(transform.position, veluga.transform.position + Vector3.up * 0.5f, degree);
        Throw(BallVelo);

        if (UInput.uIState == UInput.UIState.Ball)
        {
            //catchTF.transform.position = caTF.position;
            //catchTF.transform.SetParent(null);
            aiState.StartCoroutine(aiState.BallBall());
            StartCoroutine("DestroyBall");
        }
    }
Exemplo n.º 8
0
 private void EndActions(AIStateController controller)
 {
     foreach (var action in m_Actions)
     {
         action.End(controller);
     }
 }
Exemplo n.º 9
0
 private void DoActions(AIStateController controller)
 {
     foreach (var action in m_Actions)
     {
         action.Act(controller);
     }
 }
Exemplo n.º 10
0
 protected void UpdateActions(AIStateController controller)
 {
     foreach (AIAction action in actions)
     {
         action.UpdateAction(controller);
     }
 }
Exemplo n.º 11
0
    // 작동 될 때
    private void OnEnable()
    {
        if (f_rigid == null)
        {
            transform.SetParent(null);                                          // 부모를 없애어, 플레이어의 시각으로부터 자유로워진다.
            f_rigid      = GetComponent <Rigidbody>();
            tf           = GameObject.Find("LookChecker");
            obm          = GameObject.Find("ObjectManager");
            aiState      = GameObject.Find("BelugaAxis").GetComponent <AIStateController>();
            veTF         = GameObject.Find("BelugaAxis").GetComponent <Transform>();
            uu           = GameObject.Find("Main Camera").GetComponent <UInput>();
            foodParticle = GameObject.Find("Particle").transform.Find("Eating");
        }

        uu.fakeFish.SetActive(false);
        if (AI.success + AI.fail < 5 && UInput.uIState == UInput.UIState.Feed && Vector3.Distance(tf.transform.position, veTF.position) < 0.4f)         // 벨루가위치와 던짐 목표 위치를 비교하여 일정 거리 이하일 경우만
        {
            aiState.StartCoroutine(aiState.FeedFeed());
        }
        f_rigid.velocity = Vector3.zero;
        Vector3 foodVelo = Throwing(obm.transform.position, tf.transform.position + Vector3.up, degree);

        Throw(foodVelo);

        StartCoroutine("DestroyFood");
    }
 public override void Act(AIStateController controller)
 {
     if (controller.character.CurrentState == CharacterState.Normal)
     {
         DeployTrap(controller);
     }
 }
Exemplo n.º 13
0
    private bool Look(AIStateController controller)
    {
        controller.visibleTargets.Clear();

        Collider[] targetsInViewRadius = Physics.OverlapSphere(controller.transform.position, controller.enemyStats.lookRange, controller.targetMask);

        for (int i = 0; i < targetsInViewRadius.Length; i++)
        {
            if (targetsInViewRadius [i].GetComponent <NetworkCharacter>().Team == GameEnum.TeamType.Hunter)
            {
                Transform target      = targetsInViewRadius [i].transform;
                Vector3   dirToTarget = (target.position - controller.transform.position).normalized;
                float     dstToTarget = Vector3.Distance(controller.transform.position, target.position);
                //if (!Physics.Raycast(controller.transform.position, dirToTarget, dstToTarget, controller.obstacleMask))
                controller.visibleTargets.Add(target);
            }
        }

        if (controller.visibleTargets.Count > 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Exemplo n.º 14
0
    public override void Begin(AIStateController controller)
    {
        controller.Agent.speed            = wanderSpeed;
        controller.Agent.stoppingDistance = 0f;
        controller.Agent.angularSpeed     = wanderTurnSpeed;

        WanderDataContainer container = controller.Data.Wander;

        container.SetStartPosition(controller.transform.position);
        container.SetWanderTarget(this, controller);

        ChaseDataContainer chase = controller.Data.Chase;

        if (chase.ChaseTarget != null)
        {
            chase.SetChaseTarget(null);
        }

        AttackDataContainer attack = controller.Data.Attack;

        if (attack.DamageTarget != null)
        {
            attack.SetDamageTarget(null);
        }
    }
Exemplo n.º 15
0
    private void Flee(AIStateController controller)
    {
        controller.Look();

        bool fallback = false;
        var  planner  = controller.GetComponent <EscapePlanner>();

        if (planner && EscapeGraph.Initialized)
        {
            //Vector3 prevDest = controller.navMeshAgent.destination;
            Vector3 dest = EscapeGraph.GetDestination(controller.transform.position, controller.transform.forward, controller.visibleTargets, planner.areaName);
            if (Vector3.SqrMagnitude(dest - controller.transform.position) > 1.0f)
            {
                controller.navMeshAgent.destination      = dest;
                controller.navMeshAgent.stoppingDistance = 1e-3f;
                controller.navMeshAgent.isStopped        = false; // is this safe?
            }
            else
            {
                fallback = true;
            }
        }
        else
        {
            fallback = true;
        }


        if (fallback)
        {
            Flee_DirectOpposite(controller);
        }
    }
Exemplo n.º 16
0
 public void Attack(AIStateController controller)
 {
     //attack kill here
     controller.character.Perform("Attack", controller.gameObject, null);
     controller.chaseTarget [0].Perform("Die", controller.chaseTarget[0].gameObject, null);
     controller.chaseTarget.Remove(controller.chaseTarget [0]);
 }
Exemplo n.º 17
0
    private void SeekRefill(AIStateController controller)
    {
        if (controller.GetComponent <TankShooting>().m_Ammo < 1)
        {
            Vector3 overshoot = Vector3.Normalize(controller.navMeshAgent.transform.position - AmmoRefill.refillWaypoint);
            controller.navMeshAgent.destination = AmmoRefill.refillWaypoint + overshoot * controller.navMeshAgent.stoppingDistance;
            controller.navMeshAgent.isStopped   = false;
        }
        else if (controller.GetComponent <TankHealth>().m_CurrentHealth < 30)
        {
            Vector3 overshoot = Vector3.Normalize(controller.navMeshAgent.transform.position - HPRefill.refillWaypoint);
            controller.navMeshAgent.destination = HPRefill.refillWaypoint + overshoot * controller.navMeshAgent.stoppingDistance;
            controller.navMeshAgent.isStopped   = false;
        }

        controller.navMeshAgent.isStopped = false;

        /*
         * if (controller.navMeshAgent.remainingDistance <= controller.navMeshAgent.stoppingDistance
         *  && !controller.navMeshAgent.pathPending)
         * {
         *  if (controller.GetComponent<TankHealth>().m_CurrentHealth < 30)
         *  {
         *      controller.navMeshAgent.destination = HPRefill.refillWaypoint;
         *  }
         *  else if (controller.GetComponent<TankShooting>().m_Ammo < 1)
         *  {
         *      controller.navMeshAgent.destination = AmmoRefill.refillWaypoint;
         *  }
         * }
         */
    }
    private void GoToTarget(AIStateController controller)
    {
        if (controller.targetIndx == -1 || controller.targetIndx >= controller.wayPointList.Count || !controller.wayPointList [controller.targetIndx].gameObject.activeSelf)
        {
            /*
             * float minDis = float.MaxValue;
             * for (int i = 0; i < controller.wayPointList.Count; i++) {
             *
             *      if (IsSuitableWayPoint(controller, i)) {
             *              float tempDis = Vector3.Distance(controller.wayPointList [i].position, controller.transform.position);
             *              if (tempDis < minDis) {
             *                      minDis = tempDis;
             *                      controller.targetIndx = i;
             *              }
             *      }
             * }
             */
            AssignTargets(controller);
        }

        controller.navMeshAgent.destination = controller.wayPointList [controller.targetIndx].position;
        controller.navMeshAgent.isStopped   = false;
        if (controller.navMeshAgent.remainingDistance <= controller.navMeshAgent.stoppingDistance && !controller.navMeshAgent.pathPending)
        {
            controller.navMeshAgent.isStopped = true;
        }
    }
    private bool DetectChokePoint(AIStateController controller)
    {
        Transform self = controller.transform;

        if (controller.targetIndx >= 0 && controller.targetIndx < controller.wayPointList.Count && Vector3.Distance(self.position, controller.wayPointList [controller.targetIndx].transform.position) < 20.0f)
        {
            Vector3 forward = self.forward;
            Vector3 up      = self.up;
            Vector3 right   = Vector3.Cross(forward.normalized, up.normalized);
            Vector3 left    = -right;
            right.y = 1.0f;
            left.y  = 1.0f;
            RaycastHit hitleft;
            RaycastHit hitright;
            if (Physics.Raycast(self.position, left, out hitleft, maxDetectDistance) && Physics.Raycast(self.position, right, out hitright, maxDetectDistance))
            {
                float tempdis = Vector3.Distance(hitleft.point, hitright.point);
                if (tempdis < chokeDistance)
                {
                    return(true);
                }
            }
        }
        return(false);
    }
Exemplo n.º 20
0
 private void StartActions(AIStateController controller)
 {
     foreach (var action in m_Actions)
     {
         action.Begin(controller);
     }
 }
Exemplo n.º 21
0
    private bool Look(AIStateController controller)
    {
        GameManager manager = GameObject.Find("GameManager").GetComponent <GameManager>();
        RaycastHit  hit;

        Debug.DrawRay(controller.eyes.position,
                      controller.eyes.forward.normalized * controller.enemyStats.lookRange,
                      Color.green);

        if (Physics.SphereCast(controller.eyes.position, controller.enemyStats.lookSphereCastRadius,
                               controller.eyes.forward, out hit, controller.enemyStats.lookRange) &&
            hit.collider.CompareTag("Player"))
        {
            controller.chaseTarget = hit.transform;
            //Debug.Log("Look True");
            return(true);
        }
        else if (Vector3.Distance(controller.transform.position, manager.m_Tanks[0].m_Instance.transform.position) < 8)
        {
            //Debug.Log("Look False");
            controller.chaseTarget = manager.m_Tanks[0].m_Instance.transform;
            return(true);
        }
        else
        {
            return(false);
        }
    }
Exemplo n.º 22
0
    //Boarder Check
    private Vector3 BoarderRunOffset(AIStateController controller, Vector3 runDir)
    {
        Vector3 offsetDir = new Vector3(0, 0, 0);

        if (runDir.x >= 0 && runDir.z >= 0)
        {
            offsetDir += (10 / Mathf.Abs(northBoarder - controller.transform.position.z)) * (new Vector3(runDir.x, 0, 0)).normalized;
            offsetDir += (10 / Mathf.Abs(eastBoarder - controller.transform.position.x)) * (new Vector3(0, 0, runDir.z)).normalized;
        }
        if (runDir.x >= 0 && runDir.z < 0)
        {
            offsetDir += (10 / Mathf.Abs(southBoarder - controller.transform.position.z)) * (new Vector3(runDir.x, 0, 0)).normalized;
            offsetDir += (10 / Mathf.Abs(eastBoarder - controller.transform.position.x)) * (new Vector3(0, 0, runDir.z)).normalized;
        }
        if (runDir.x < 0 && runDir.z >= 0)
        {
            offsetDir += (10 / Mathf.Abs(northBoarder - controller.transform.position.z)) * (new Vector3(runDir.x, 0, 0)).normalized;
            offsetDir += (10 / Mathf.Abs(westBoarder - controller.transform.position.x)) * (new Vector3(0, 0, runDir.z)).normalized;
        }
        if (runDir.x < 0 && runDir.z < 0)
        {
            offsetDir += (10 / Mathf.Abs(southBoarder - controller.transform.position.z)) * (new Vector3(runDir.x, 0, 0)).normalized;
            offsetDir += (10 / Mathf.Abs(westBoarder - controller.transform.position.x)) * (new Vector3(0, 0, runDir.z)).normalized;
        }
        return(offsetDir);
    }
Exemplo n.º 23
0
 private void DoActions(AIStateController controller)
 {
     for (int i = 0; i < actions.Length; i++)
     {
         actions [i].Act(controller);
     }
 }
Exemplo n.º 24
0
    public void DamageAround(AIStateController ai, float radious, int damage)
    {
        //yield return new WaitForSeconds(3);
        foreach (AIStateController AI in aiStateControllers)
        {
            if (AI.IsEnable)
            {
                Debug.Log(ai.Role.name + "and target - " + AI.Role.name + "is" + Vector3.Distance(ai.RolePos, AI.RolePos));
                if (Vector3.Distance(ai.Role.transform.position, AI.Role.transform.position) < radious && AI != ai)
                {
                    Debug.Log("BombUnderTakeDamage");
                    //AI.Role.GetComponent<PlayerHealth>().currenthp -= damage;
                    StartCoroutineEvent(Bombdamage(AI, (damage - (damage / 2)), 3));
                }
            }
        }

        foreach (AIStateController AI in enemyaiStateControllers)
        {
            if (AI.IsEnable)
            {
                Debug.Log(ai.Role.name + "and target - " + AI.Role.name + "is" + Vector3.Distance(ai.RolePos, AI.RolePos));
                if (Vector3.Distance(ai.Role.transform.position, AI.Role.transform.position) < radious && AI != ai)
                {
                    Debug.Log("BombUnderTakeDamage");
                    //AI.Role.GetComponent<PlayerHealth>().currenthp -= damage;
                    StartCoroutineEvent(Bombdamage(AI, damage, 3));
                }
            }
        }

        foreach (AIStateController AI in combineaiStateControllers)
        {
            if (AI.IsEnable)
            {
                Debug.Log(ai.Role.name + "and target - " + AI.Role.name + "is" + Vector3.Distance(ai.RolePos, AI.RolePos));
                if (Vector3.Distance(ai.Role.transform.position, AI.Role.transform.position) < radious && AI != ai)
                {
                    Debug.Log("BombUnderTakeDamage");
                    //AI.Role.GetComponent<PlayerHealth>().currenthp -= damage;
                    StartCoroutineEvent(Bombdamage(AI, damage, 3));
                }
            }
        }

        foreach (AIStateController AI in groupEnemyAIStateControllers)
        {
            if (AI.IsEnable)
            {
                Debug.Log(ai.Role.name + "and target - " + AI.Role.name + "is" + Vector3.Distance(ai.RolePos, AI.RolePos));
                if (Vector3.Distance(ai.Role.transform.position, AI.Role.transform.position) < radious && AI != ai)
                {
                    Debug.Log("BombUnderTakeDamage");
                    //AI.Role.GetComponent<PlayerHealth>().currenthp -= damage;
                    StartCoroutineEvent(Bombdamage(AI, 3, 3));
                }
            }
        }
    }
Exemplo n.º 25
0
 private void DoActions(AIStateController controller)
 {
     for (int i = 0; i < actions.Length; i++)
     {
         //Debug.Log("AIState UpdateState " + actions[i]);
         actions[i].Act(controller);
     }
 }
    public override bool Decide(AIStateController controller)
    {
        //Debug.Log (controller.targetIndx);
        bool ispowerSourceActive = controller.survivorsk.m_InteractingPowerSource != null && controller.survivorsk.m_InteractingPowerSource.gameObject.activeSelf;

        //Debug.Log (ispowerSourceActive);
        return(ispowerSourceActive);
    }
    public void SetWanderTarget(WanderAction action, AIStateController controller)
    {
        Vector2 v = Random.insideUnitCircle * action.WanderDistance;

        wanderTarget = startPosition + new Vector3(v.x, 0, v.y);
        controller.Agent.destination = wanderTarget;
        controller.Animator.SetInteger("Walk", 1);
    }
Exemplo n.º 28
0
    private void Chase(AIStateController controller)
    {
        Vector3 side1 = (controller.chaseTarget.position - controller.transform.position).normalized;
        Vector3 side2 = (controller.eyes.forward);

        controller.navMeshAgent.destination = controller.chaseTarget.position;
        controller.navMeshAgent.isStopped   = false;
    }
 public override void Act(AIStateController controller)
 {
     if (controller.character.CurrentState != CharacterState.Normal)
     {
         return;
     }
     GoToTarget(controller);
 }
 public void UpdateIntervalTime(ChaseAction action, AIStateController controller)
 {
     currentPathUpdateIntervalTime += Time.deltaTime;
     if (currentPathUpdateIntervalTime > action.PathUpdateIntervalTime)
     {
         currentPathUpdateIntervalTime = 0;
         UpdatePath(controller);
     }
 }