Ejemplo n.º 1
0
        void OnUnitDeath(UnitController unit)
        {
            unit.enabled = false;

            unit.Animator.applyRootMotion = true;
            unit.Animator.Play("Dying");
            unit.Animator.SetBool("isInteracting", true);
            unit.UnitCollider.enabled = false;
            unit.GetComponentInChildren <InteractionHook>().enabled = false;

            Collider[] colliders = unit.GetComponentsInChildren <Collider>();
            foreach (Collider c in colliders)
            {
                c.gameObject.layer = 9;
            }
            unit.Animator.transform.parent = null;

            if (unit.onDeathEnableCollider != null)
            {
                unit.onDeathEnableCollider.SetActive(true);
            }
        }
Ejemplo n.º 2
0
        List <Node> GetNeighbours(Node from, UnitController unit)
        {
            List <Node> result = new List <Node>();

            for (int x = -1; x <= 1; x++)
            {
                for (int z = -1; z <= 1; z++)
                {
                    if (x == 0 && z == 0)
                    {
                        continue;
                    }

                    int _x = x + from.position.x;
                    int _y = from.position.y;
                    int _z = z + from.position.z;

                    if (_x == from.position.x && _z == from.position.z)
                    {
                        continue;
                    }

                    Node node = GridManager.instance.GetNode(_x, _y, _z, unit.GridIndex);

                    if (_x == unit.CurrentNode.position.x &&
                        _z == unit.CurrentNode.position.z)
                    {
                        result.Add(unit.CurrentNode);
                    }
                    else if (node != null && node.IsWalkable())
                    {
                        result.Add(node);
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 3
0
        public override void LoadAction(GridUnit gridUnit)
        {
            if (gridUnit != null)
            {
                UnitController  unitController = (UnitController)gridUnit;
                InteractionHook ih             = gridUnit.currentInteractionHook;

                if (ih != null)
                {
                    //Basically always the same, since we just want to store interactionHook
                    if (unitController.AttackType.Equals(UnitAttackType.RANGED))
                    {
                        ih.interaction = new InitiateRangedAttack();
                    }
                    else if (unitController.AttackType.Equals(UnitAttackType.MELEE))
                    {
                        ih.interaction = new InitiateMeleeAttack();
                    }
                    else if (unitController.AttackType.Equals(UnitAttackType.MAGIC))
                    {
                        Debug.Log("Future magic attack");
                        //ih.interaction = new InitiateMagicAttack();
                    }
                    else
                    {
                        Debug.Log("Missing attack type!");
                    }

                    gridUnit.StoreInteractionHook(ih);
                    return;
                }
                else
                {
                    Debug.Log("Ih is null!");
                }
            }
        }
Ejemplo n.º 4
0
        public override bool TickIsFinished(GridUnit gridUnit, float deltaTime)
        {
            timer -= deltaTime;

            RotateTargetUnit(gridUnit, deltaTime);

            Vector3 direction = (gridUnit.currentInteractionHook.transform.position - gridUnit.transform.position).normalized;

            direction.y = 0;
            Quaternion rotation = Quaternion.LookRotation(direction);

            gridUnit.transform.rotation = Quaternion.Slerp(gridUnit.transform.rotation, rotation, deltaTime / .3f);

            UnitController unitController = (UnitController)gridUnit;

            if (timer <= 0)
            {
                if (unitController.ProjectileHitTarget)
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 5
0
 public FlowmapPathfinder(GridManager gridManager, UnitController unitController, OnCompleteCallback onCompleteCallback = null)
 {
     this.gridManager        = gridManager;
     this.unitController     = unitController;
     this.onCompleteCallback = onCompleteCallback;
 }
Ejemplo n.º 6
0
 public CombatEvent(UnitController initiator, UnitController receiver)
 {
     this.initiator = initiator;
     this.receiver  = receiver;
 }
Ejemplo n.º 7
0
 public void OnDoAction(UnitController unit)
 {
     unit.LoadGridActionToMove(path, animationClip);
     unit.PlayAnimation(actionAnimation);
     BattleManager.instance.unitIsMoving = true;
 }
Ejemplo n.º 8
0
        public override void OnEnd(GridUnit gridUnit)
        {
            UnitController unitController = (UnitController)gridUnit;

            unitController.HitReceivedCompleted();
        }
Ejemplo n.º 9
0
 public AttackReceived(UnitController initiator, AnimationClip animationClip, string animation)
 {
     this.initiator     = initiator;
     this.animationClip = animationClip;
     this.animation     = animation;
 }