Exemplo n.º 1
0
 void Awake()
 {
     aiUnit                = GetComponent <CharacterControl> ();
     animator              = GetComponentInChildren <Animator> ();
     pandaTree             = GetComponent <PandaBehaviour> ();
     team                  = aiUnit.CharacterData.Team;
     LastGetHitTime        = Mathf.NegativeInfinity;
     LastTargetAttackTime  = Mathf.NegativeInfinity;
     LastTargetExecuteTime = Mathf.NegativeInfinity;
     LastTargetDodgeTime   = Mathf.NegativeInfinity;
     LastTargetGuardTime   = Mathf.NegativeInfinity;
     enemyTarget           = null;
     AIAgentManager.Instance.TotalAIAgent.Add(this);
 }
Exemplo n.º 2
0
        public void MoveForward(CharacterControl control, Animator animator, AnimatorStateInfo animatorStateInfo)
        {
            Vector3 moveDirection   = control.FaceTarget;
            Vector3 deltaMoveAmount = moveDirection * animator.GetFloat(TransitionParameter.SpeedMultiplier.ToString()) * control.CharacterData.CurrentDisplacementSpeed * speedGraph.Evaluate(animatorStateInfo.normalizedTime) * Time.deltaTime;

            float      dist = GetCurrentDist(control);
            RaycastHit hit;
            int        layermask = 1 << 10;

            if ((dist >= 0.3f || dist < 0f) && !Physics.BoxCast(control.transform.position, new Vector3(0.2f, 1.0f, 0.2f), moveDirection, out hit, control.transform.rotation, 1f, layermask))
            {
                control.transform.Translate(deltaMoveAmount, Space.World);
            }
        }
Exemplo n.º 3
0
 public bool CheckLink(CharacterControl control)
 {
     bool[] input = control.inputKeyStates;
     switch (LinkType)
     {
     case TransitionParameter.AttackMeleeLink:
         if (input[(int)InputKeyType.KEY_MELEE_ATTACK * 3])
         {
             return(true);
         }
         break;
     }
     return(false);
 }
Exemplo n.º 4
0
        public void RegisterAllUnit()
        {
            ManualInput playerInput = null;

            if (Player == null)
            {
                playerInput = FindObjectOfType(typeof(ManualInput)) as ManualInput;
                Player      = playerInput.GetComponent <CharacterControl> ();
            }
            playerInput         = Player.GetComponent <ManualInput> ();
            playerInput.enabled = true;

            AIAgentManager.Instance.RegisterAllEnemies();
        }
Exemplo n.º 5
0
 public void Init(AttackInfo projectileInfo, float duration, float speed)
 {
     ProjectileInfo              = projectileInfo;
     Owner                       = projectileInfo.Attacker;
     CurrentTime                 = 0;
     Duration                    = duration;
     Speed                       = speed;
     IsMoving                    = true;
     SpeedGraph                  = projectileInfo.ProjectileSkill.SpeedGraph;
     ScaleGraph                  = projectileInfo.ProjectileSkill.ScaleGraph;
     ProjectileScale             = projectileInfo.ProjectileSkill.ProjectileScale;
     IsAOERangeChangeWithScaling = projectileInfo.IsAOERangeChangeWithScaling;
     IsVFXScaleChangeWithScaling = projectileInfo.IsVFXScaleChangeWithScaling;
 }
Exemplo n.º 6
0
        public void ControlledMove(CharacterControl control, Animator animator, AnimatorStateInfo animatorStateInfo)
        {
            Vector2 inputVector = control.inputVector;

            //Debug.Log(inputVector);

            if (inputVector.magnitude > 0.01f)
            {
                //animator.SetBool (TransitionParameter.Move.ToString (), true);
                if (animatorStateInfo.IsName("Move") ||
                    animatorStateInfo.IsName("Walk") ||
                    animatorStateInfo.IsName("Dodge_Tumbling") ||
                    animatorStateInfo.IsName("Run"))
                {
                    Vector3 moveDirection = new Vector3(inputVector.x, 0, inputVector.y);
                    //MoveForward (moveDirection, speed, 1.0f);
                    Vector3 deltaMoveAmount = moveDirection * animator.GetFloat(TransitionParameter.SpeedMultiplier.ToString()) * speed * speedGraph.Evaluate(animatorStateInfo.normalizedTime) * Time.deltaTime;

                    /*
                     * if (ConsiderMomentum) {
                     *  if (control.CharacterData.GetPrevState () == Animator.StringToHash ("Move") ||
                     *      control.CharacterData.GetPrevState () == Animator.StringToHash ("Dodge_End") ||
                     *      control.CharacterData.GetPrevState () == Animator.StringToHash ("Dodge_Tumbling") ||
                     *      control.CharacterData.GetPrevState () == Animator.StringToHash ("Run")) {
                     *      Debug.Log (control.CharacterData.GetPrevState () == Animator.StringToHash ("Dodge_End"));
                     *      Debug.Log (control.CharacterData.GetPrevState () == Animator.StringToHash ("Dodge_Tumbing"));
                     *      Vector3 extraDeltaMove = moveDirection * control.CharacterController.velocity.magnitude;
                     *      extraDeltaMove = extraDeltaMove * animator.GetFloat (TransitionParameter.SpeedMultiplier.ToString ()) * extraSpeedGraph.Evaluate (animatorStateInfo.normalizedTime) * Time.deltaTime;
                     *      deltaMoveAmount = deltaMoveAmount + extraDeltaMove;
                     *  }
                     * }
                     */
                    control.CharacterController.Move(deltaMoveAmount);
                    //animator.transform.root.Translate(moveDirection * speed * Time.deltaTime);
                    //animator.transform.Translate(moveDirection * speed * Time.deltaTime);

                    if (!animatorStateInfo.IsName("Walk"))
                    {
                        Quaternion rotation = Quaternion.LookRotation(moveDirection, Vector3.up);
                        animator.gameObject.transform.root.rotation = Quaternion.Slerp(animator.gameObject.transform.root.rotation, rotation, Time.deltaTime * 5f);
                        //float angle = Mathf.Acos(Vector3.Dot(new Vector3(0, 0, 1), moveDirection)) * Mathf.Rad2Deg;
                        //if (inputVector.x < 0.0f) { angle = -angle; }
                        //Quaternion target = Quaternion.Euler(new Vector3(0, angle, 0));
                        //animator.transform.localRotation = Quaternion.Slerp(animator.transform.localRotation, target, Time.deltaTime * smooth);
                    }
                }
            }
        }
        IEnumerator _SetFormerTarget(CharacterControl target, float duration)
        {
            this.Animator.SetBool(TransitionParameter.LockOnEnemy.ToString(), true);
            this.CharacterData.FormerAttackTarget = target;
            float t = 0f;

            while (t < duration)
            {
                t += Time.deltaTime;
                //Debug.Log(t);
                yield return(null);
            }
            this.CharacterData.FormerAttackTarget = null;
            SetFormerTargetCoroutine = null;
            this.Animator.SetBool(TransitionParameter.LockOnEnemy.ToString(), false);
        }
        private void OnTriggerEnter (Collider col) {
            attacker = col.GetComponentInParent<CharacterControl> ();
            //if (Control == attacker || attacker.GetTriggerDetector().gameObject == col.gameObject)
            if (attacker == null)
                return;
            if (Control == attacker)
                return;
            if (!attacker.AttackingParts.Contains (col) && attacker.AttackPoint != col)
                return;
            //if(Control == attacker)
            //if (attacker == null || Control == attacker || attacker.GetTriggerDetector().gameObject == col.gameObject)

            if (!CollidingParts.Contains (col))
                CollidingParts.Add (col);

        }
Exemplo n.º 9
0
 public void Init(GrapplingSkill grapplingSkill, CharacterControl attacker)
 {
     Skill                  = grapplingSkill;
     IsRegistered           = false;
     IsFinished             = false;
     CurrentTargetNum       = 0;
     Type                   = grapplingSkill.Type;
     Mode                   = grapplingSkill.Mode;
     Range                  = grapplingSkill.Range;
     Damage                 = grapplingSkill.Damage;
     Stun                   = grapplingSkill.Stun;
     FreezeStartTiming      = grapplingSkill.FreezeStartTiming;
     Attacker               = attacker;
     Target                 = null;
     CheckCompleteCoroutine = null;
 }
        /*
         * public void MoveCharacter()
         * {
         *
         * }
         */
        public void SetFormerTarget(CharacterControl target, float duration)
        {
            if (SetFormerTargetCoroutine != null)
            {
                StopCoroutine(SetFormerTargetCoroutine);
            }

            if (target != null)
            {
                SetFormerTargetCoroutine = StartCoroutine(_SetFormerTarget(target, duration));
            }
            else
            {
                this.CharacterData.FormerAttackTarget = null;
            }
        }
Exemplo n.º 11
0
        IEnumerator _PlayCloseUp(CharacterControl player)
        {
            controller.RemoveFromCloseUpTargetGroup(player);
            controller.RemoveFromCloseUpTargetGroup(player.CharacterData.GrapplingTarget);
            controller.AddToCloseUpTargetGroup(player);
            controller.AddToCloseUpTargetGroup(player.CharacterData.GrapplingTarget);
            controller.TriggerCamera(CameraType.CloseUp);
            float t = 0f;

            while (t < 0.25f)
            {
                controller.ZoomCameraPerFrame(-20f * Time.deltaTime);
                t = t + Time.deltaTime;
                yield return(null);
            }
        }
Exemplo n.º 12
0
 public void OnUnitDead(CharacterControl unit)
 {
     if (unit == Player)
     {
         GameOver();
     }
     else
     {
         if (!CurrLevelData.HasCompleted)
         {
             Quest CurrQuest = CurrLevelData.Quests[CurrQuestIndex];
             CurrQuest.CurrKilledEnemyNum++;
             UpdateState();
         }
     }
 }
Exemplo n.º 13
0
        public void SpawnUnit(Vector3 position, Vector3 rotVec, string prefabName)
        {
            GameObject obj = Instantiate(Resources.Load(prefabName, typeof(GameObject)) as GameObject);

            //obj.SetActive (true);
            obj.transform.position = position;
            obj.transform.rotation = Quaternion.LookRotation(rotVec, Vector3.up);
            CharacterControl control = obj.GetComponent <CharacterControl> ();

            control.Init();
            control.Spawn();
            if (control.isPlayerControl)
            {
                CameraManager.Instance.Init();
                GameManager.Instance.SetPlayer(control);
            }
        }
Exemplo n.º 14
0
        public override void OnEnter(StatewithEffect stateEffect, Animator animator, AnimatorStateInfo stateInfo)
        {
            //curveArea = AreaUnderCurve (speedGraph, 1.0f, 1.0f);
            CharacterControl control = stateEffect.CharacterControl;
            float            dist    = GetCurrentDist(control);

            if (dist > 0f)
            {
                float speed = dist / (stateInfo.length * curveArea);
                speed = Mathf.Min(speed, maxSpeed);
                control.CharacterData.CurrentDisplacementSpeed = speed;
            }
            else
            {
                control.CharacterData.CurrentDisplacementSpeed = maxSpeed;
            }
        }
Exemplo n.º 15
0
        public void SetPosition(CharacterControl control, Animator animator, AnimatorStateInfo animatorStateInfo)
        {
            Vector3    moveDirection = control.FaceTarget;
            RaycastHit hit;
            int        layermask = 1 << 10;

            //Gizmos.DrawWireCube(control.transform.position + 1f * moveDirection, new Vector3(1.0f,1.0f,0.2f));
            if (!Physics.BoxCast(control.transform.position, new Vector3(0.2f, 1.0f, 0.2f), moveDirection, out hit, control.transform.rotation, 1f, layermask))
            {
                Vector3 deltaMoveAmount = moveDirection * speed * speedGraph.Evaluate(animatorStateInfo.normalizedTime) * Time.deltaTime;
                if (!ignoreSpeedMultiplier)
                {
                    deltaMoveAmount = deltaMoveAmount * animator.GetFloat(TransitionParameter.SpeedMultiplier.ToString());
                }
                control.transform.Translate(deltaMoveAmount, Space.World);
            }
        }
Exemplo n.º 16
0
 public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (characterControl == null)
     {
         //characterControl = animator.transform.root.GetComponentInChildren<CharacterControl> ();
         characterControl = animator.transform.root.GetComponent <CharacterControl> ();
     }
     if (characterControl != null)
     {
         characterControl.CharacterData.LoadState(stateInfo.shortNameHash);
         //Debug.Log(stateInfo.shortNameHash);
         foreach (SkillEffect se in ListSkillEffect)
         {
             se.OnEnter(this, animator, stateInfo);
         }
     }
 }
Exemplo n.º 17
0
 public float GetCurrentDist(CharacterControl control)
 {
     if (control.CharacterData.FormerAttackTarget != null && !control.CharacterData.FormerAttackTarget.CharacterData.IsDead)
     {
         Vector3 currDistVec = Vector3.zero;
         if (Type == TargetType.FormerTarget)
         {
             currDistVec = control.CharacterData.FormerAttackTarget.gameObject.transform.position - control.gameObject.transform.position;
         }
         else if (Type == TargetType.FormerTargetProjectileSpawnPoint)
         {
             currDistVec = control.CharacterData.FormerAttackTarget.GetProjectileSpawnPoint().gameObject.transform.position - control.gameObject.transform.position;
         }
         currDistVec.y = 0f;
         return(currDistVec.magnitude);
     }
     return(-1f);
 }
Exemplo n.º 18
0
        public bool CheckCurrQuestComplete()
        {
            Debug.Log("check current quest complete");
            Quest CurrQuest = CurrLevelData.Quests[CurrQuestIndex];

            switch (CurrQuest.Type)
            {
            case QuestType.KillAllEnemies:
                if (CurrQuest.Enemies.Count == CurrQuest.CurrKilledEnemyNum)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }

            case QuestType.DestroyTarget:
                CharacterControl control = CurrQuest.GoalObject.GetComponent <CharacterControl> ();
                if (control.CharacterData.IsDead)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }

            case QuestType.ReachPosition:
                Vector3 distVec = Player.gameObject.transform.position - CurrQuest.GoalObject.gameObject.transform.position;
                distVec.y = 0f;
                if (distVec.magnitude < 2.0f)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }

            default:
                return(false);
            }
        }
Exemplo n.º 19
0
 public bool CheckCollision(StatewithEffect stateEffect, Animator animator, AnimatorStateInfo stateInfo)
 {
     if (onlyCheckLockedTarget)
     {
         CharacterControl enemy = stateEffect.CharacterControl.CharacterData.FormerAttackTarget;
         if (enemy != null)
         {
             Vector3 DistVec = enemy.gameObject.transform.position - stateEffect.CharacterControl.gameObject.transform.position;
             DistVec.y = 0f;
             if (DistVec.magnitude <= collisionRange)
             {
                 return(true);
             }
         }
     }
     else
     {
         // not complete
     }
     return(false);
 }
 public void OnEnemyGetDamaged(SkillEffect skill, CharacterControl enemy)
 {
     //Debug.Log (skill.GetType ().ToString ());
     if (enemy.CharacterData.HP <= 0f)
     {
         this.CharacterData.CurrentEnergyUnitChargeToFull();
         if (skill.GetType().ToString() == "meleeDemo.DirectDamage")
         {
             this.CharacterData.GetEnergy(this.CharacterData.EnergyGetOnEnemyDeathByExecute);
         }
         else if (skill.GetType().ToString() == "meleeDemo.Attack")
         {
             if (((Attack)skill).IsLethalToStunnedEnemy)
             {
                 this.CharacterData.GetEnergy(this.CharacterData.EnergyGetOnEnemyDeathByExecute);
             }
         }
     }
     else
     {
         if (skill.GetType().ToString() == "meleeDemo.DirectDamage")
         {
             float EnergyGet = ((DirectDamage)skill).EnergyGetWhenHit;
             if (EnergyGet > 0)
             {
                 this.CharacterData.GetEnergyToMaxOneUnit(EnergyGet);
             }
         }
         else if (skill.GetType().ToString() == "meleeDemo.Attack")
         {
             float EnergyGet = ((Attack)skill).EnergyGetWhenHit;
             if (EnergyGet > 0)
             {
                 this.CharacterData.GetEnergyToMaxOneUnit(EnergyGet);
             }
             this.SetFormerTarget(enemy, 1f);
         }
     }
 }
Exemplo n.º 21
0
        public void RegisterDamageEvent()
        {
            //Debug.Log ("register damage event!");
            ManualInput playerObjManu = FindObjectOfType(typeof(ManualInput)) as ManualInput;

            if (playerObjManu != null)
            {
                CharacterControl player = playerObjManu.GetComponent <CharacterControl> ();

                /*
                 * foreach(Delegate exist in aiUnit.CharacterData.OnDamage.GetInvocationList())
                 * {
                 *  if(player.OnEnemyGetDamaged == exist)
                 *      return;
                 * }
                 */
                aiUnit.CharacterData.OnDamage -= player.OnEnemyGetDamaged;
                aiUnit.CharacterData.OnDamage += player.OnEnemyGetDamaged;
                aiUnit.CharacterData.OnDead   -= GameManager.Instance.OnUnitDead;
                aiUnit.CharacterData.OnDead   += GameManager.Instance.OnUnitDead;
            }
        }
Exemplo n.º 22
0
        public Vector3 FaceEnemy(StatewithEffect stateEffect, Animator animator, AnimatorStateInfo stateInfo, Vector3 initFaceDirection, bool firstCheckFar)
        {
            Vector3 FaceTarget       = Vector3.zero;
            Vector3 formerTargetPos  = Vector3.zero;
            Vector3 originPos        = stateEffect.CharacterControl.gameObject.transform.position;
            bool    faceFormerTarget = false;

            if (stateEffect.CharacterControl.CharacterData.FormerAttackTarget != null && !stateEffect.CharacterControl.CharacterData.FormerAttackTarget.CharacterData.IsDead)
            {
                formerTargetPos  = stateEffect.CharacterControl.CharacterData.FormerAttackTarget.gameObject.transform.position;
                faceFormerTarget = (ForceFaceFormerTarget || (FaceFormerTargetFirst && (CheckTargetInRange(formerTargetPos, originPos, initFaceDirection, firstCheckFar) > 0f)));
            }
            if (faceFormerTarget)
            {
                // face former target
                Vector3 diffVectorRaw = formerTargetPos - originPos;
                Vector3 diffVector    = new Vector3(diffVectorRaw.x, 0f, diffVectorRaw.z);
                FaceTarget = diffVector.normalized;
                stateEffect.CharacterControl.SetFormerTarget(stateEffect.CharacterControl.CharacterData.FormerAttackTarget, LockOnTargetDuration);
            }
            else
            {
                // find new enemy
                CharacterControl enemy = CaptureEnemy(initFaceDirection, stateEffect, animator, stateInfo, firstCheckFar);
                if (enemy == null)
                {
                    FaceTarget = initFaceDirection;
                    //stateEffect.CharacterControl.SetFormerTarget (null, 0f);
                }
                else
                {
                    Vector3 diffVectorRaw = enemy.gameObject.transform.position - originPos;
                    Vector3 diffVector    = new Vector3(diffVectorRaw.x, 0f, diffVectorRaw.z);
                    FaceTarget = diffVector.normalized;
                    stateEffect.CharacterControl.SetFormerTarget(enemy, LockOnTargetDuration);
                }
            }
            return(FaceTarget);
        }
Exemplo n.º 23
0
        public override void UpdateEffect(StatewithEffect stateEffect, Animator animator, AnimatorStateInfo stateInfo)
        {
            CharacterControl control    = stateEffect.CharacterControl;
            Vector3          FaceTarget = animator.transform.root.forward;

            float distDecayFactor = 1.0f;

            if (control.CharacterData.FormerAttackTarget != null)
            {
                Vector3 dir = control.CharacterData.FormerAttackTarget.gameObject.transform.position - control.gameObject.transform.position;
                dir.y = 0f;
                if (dir.magnitude <= decayRange)
                {
                    distDecayFactor = Mathf.Sqrt(dir.magnitude / decayRange);
                }
                FaceTarget = dir.normalized;
            }
            Quaternion rotation = Quaternion.LookRotation(FaceTarget, Vector3.up);

            animator.transform.root.rotation = Quaternion.Slerp(animator.transform.root.rotation, rotation, Time.deltaTime * smooth);

            float deltaAngle = 90f;

            if (direction == 0)
            {
                deltaAngle = deltaAngle * ((Random.Range(0, 2) * 2) - 1);
            }
            else
            {
                deltaAngle = deltaAngle * direction;
            }

            Vector3 moveDirection = Quaternion.AngleAxis(deltaAngle, Vector3.up) * FaceTarget;

            Vector3 deltaMoveAmount = moveDirection * animator.GetFloat(TransitionParameter.SpeedMultiplier.ToString()) * speed * speedGraph.Evaluate(stateInfo.normalizedTime) * Time.deltaTime * distDecayFactor;

            control.CharacterController.Move(deltaMoveAmount);
        }
Exemplo n.º 24
0
        public void MoveForward(CharacterControl control, Animator animator, AnimatorStateInfo animatorStateInfo)
        {
            Vector3 moveDirection   = control.FaceTarget;
            Vector3 deltaMoveAmount = moveDirection * animator.GetFloat(TransitionParameter.SpeedMultiplier.ToString()) * speed * speedGraph.Evaluate(animatorStateInfo.normalizedTime) * Time.deltaTime;

            if (ConsiderMomentum)
            {
                if (control.CharacterData.GetPrevState() == Animator.StringToHash("Move") ||
                    control.CharacterData.GetPrevState() == Animator.StringToHash("Dodge_End") ||
                    control.CharacterData.GetPrevState() == Animator.StringToHash("Dodge_Tumbling") ||
                    control.CharacterData.GetPrevState() == Animator.StringToHash("Run"))
                {
                    Vector3 extraDeltaMove = moveDirection * control.CharacterController.velocity.magnitude;
                    extraDeltaMove  = extraDeltaMove * animator.GetFloat(TransitionParameter.SpeedMultiplier.ToString()) * extraSpeedGraph.Evaluate(animatorStateInfo.normalizedTime) * Time.deltaTime;
                    deltaMoveAmount = deltaMoveAmount + extraDeltaMove;
                }
            }
            if (MoveY)
            {
                deltaMoveAmount = deltaMoveAmount + Vector3.up * animator.GetFloat(TransitionParameter.SpeedMultiplier.ToString()) * speedY * YSpeedGraph.Evaluate(animatorStateInfo.normalizedTime) * Time.deltaTime;
            }
            control.CharacterController.Move(deltaMoveAmount);
        }
Exemplo n.º 25
0
        public void GenerateShadow(StatewithEffect stateEffect, Animator animator, AnimatorStateInfo stateInfo)
        {
            if (animator.IsInTransition(0))
            {
                return;
            }
            GameObject      shadowObj  = PoolManager.Instance.GetObject(PoolObjectType.Shadow);
            PoolObject      shadow     = shadowObj.GetComponent <PoolObject> ();
            MaterialChanger matChanger = shadowObj.GetComponent <MaterialChanger> ();

            CharacterControl player         = stateEffect.CharacterControl;
            Animator         shadowAnimator = shadowObj.GetComponentInChildren <Animator> ();

            shadowObj.SetActive(true);
            matChanger.TurnOffRenderers();

            shadowAnimator.Play(player.CharacterData.GetCurrState(), -1, stateInfo.normalizedTime);
            shadowAnimator.SetFloat(TransitionParameter.SpeedMultiplier.ToString(), 0f);
            shadow.WaitAndDestroy(ShadowDuration);
            matChanger.ChangeTransparency(ShadowDuration);
            shadowObj.transform.position = player.gameObject.transform.position;
            shadowObj.transform.rotation = player.gameObject.transform.rotation;
            matChanger.TurnOnRenderersDelay(0.05f);
        }
Exemplo n.º 26
0
        public CharacterControl CaptureEnemy(Vector3 initFaceDirection, StatewithEffect stateEffect, Animator animator, AnimatorStateInfo stateInfo, bool firstCheckFar)
        {
            Vector3          direction      = Vector3.zero;
            bool             EnemyCaptured  = false;
            CharacterControl capturedTarget = null;

            //Debug.Log("test far range enemy capture");
            List <GameObject> enemyObjs = new List <GameObject> ();

            if (stateEffect.CharacterControl.isPlayerControl)
            {
                foreach (AIProgress ai in AIAgentManager.Instance.TotalAIAgent)
                {
                    enemyObjs.Add(ai.gameObject);
                }
            }
            else
            {
                // AI controlled
                if (stateEffect.CharacterControl.AIProgress.enemyTarget != null)
                {
                    enemyObjs.Add(stateEffect.CharacterControl.AIProgress.enemyTarget.gameObject);
                }
            }

            // need update
            // get enemy list

            float            finalDist           = Mathf.Infinity;
            float            stunnedEnemyDist    = Mathf.Infinity;
            CharacterControl nearestStunnedEnemy = null;
            CharacterControl CapturedEnemy       = null;

            foreach (GameObject enemy in enemyObjs)
            {
                float Dist = CheckTargetInRange(enemy.transform.position, stateEffect.CharacterControl.gameObject.transform.position, initFaceDirection, firstCheckFar);
                if (Dist > 0f)
                {
                    CharacterControl currentTarget = enemy.GetComponent <CharacterControl> ();
                    if (FaceStunnedEnemyFirst && currentTarget.CharacterData.IsStunned && Dist < stunnedEnemyDist)
                    {
                        EnemyCaptured = true;
                        //directionStunned = diffVector.normalized;
                        stunnedEnemyDist    = Dist;
                        nearestStunnedEnemy = currentTarget;
                        //Debug.Log("enemy captured!");
                    }
                    if (Dist < finalDist)
                    {
                        EnemyCaptured = true;
                        //directionFar = diffVector.normalized;
                        finalDist     = Dist;
                        CapturedEnemy = currentTarget;
                        //Debug.Log("enemy captured!");
                    }
                }
            }
            if (nearestStunnedEnemy != null)
            {
                capturedTarget = nearestStunnedEnemy;
                //direction = directionStunned;
            }
            else if (EnemyCaptured)
            {
                capturedTarget = CapturedEnemy;
            }
            //direction = directionFar;

            return(capturedTarget);
        }
Exemplo n.º 27
0
 public void RemoveFromTargetGroup(CharacterControl unit)
 {
     controller.RemoveFromTargetGroup(unit);
 }
Exemplo n.º 28
0
        public void MoveY(CharacterControl control, Animator animator, AnimatorStateInfo animatorStateInfo)
        {
            Vector3 deltaMoveAmount = Vector3.up * animator.GetFloat(TransitionParameter.SpeedMultiplier.ToString()) * speed * speedGraph.Evaluate(animatorStateInfo.normalizedTime) * Time.deltaTime;

            control.transform.Translate(deltaMoveAmount, Space.World);
        }
Exemplo n.º 29
0
 public void UpdateTargetWeight(CharacterControl unit)
 {
     controller.UpdateTargetWeight(unit);
 }
Exemplo n.º 30
0
 void Awake()
 {
     player = GetComponent <CharacterControl> ();
     menu   = GetComponent <MenuController> ();
 }