示例#1
0
    public override IEnumerator Attack(Target target)
    {
        currentTarget = target;

        //See if they are next to enemies which will later incur penalties to hit.
        RangeFinder.FindAdjacentUnits(owner);
        foreach (Unit unit in owner.adjacentUnits)
        {
            if (unit.unitInfo.faction != owner.unitInfo.faction)
            {
                NextToEnemy = true;
                break;
            }
        }

        owner.remainingActions--;
        owner.aimingBow = true;
        owner.FaceDirection(currentTarget.unitTargeted.gameObject.transform.position);
        yield return(new WaitForSeconds(0.3f));

        owner.unitAnim.SetTrigger("rangedAttack");

        yield return(new WaitForSeconds(owner.unitAnim.GetCurrentAnimatorStateInfo(0).length + 2));

        Initiative.EndAction();

        yield break;
    }
示例#2
0
 public override void ExecuteAction(ActionCost actionCost)
 {
     Initiative.queuedActions++;
     actioningUnit.GetComponent <TacticsMovement>().remainingMove    += actioningUnit.unitInfo.currentMove;
     actioningUnit.GetComponent <TacticsMovement>().remainingActions -= 1;
     actioningUnit.UpdateBreath(-1, true);
     Initiative.EndAction();
 }
示例#3
0
 public void Reload(ActionCost actionCost)
 {
     rangedWeaponData.currentAmmo = rangedWeaponData.maxAmmo;
     //DamagePopUp.Create(transform.position + new Vector3(0, gameObject.GetComponent<TacticsMovement>().halfHeight), "Arrow nocked", false);
     gameObject.GetComponent <UnitPopUpManager>().AddPopUpInfo("arrow nocked");
     if (actionCost == ActionCost.main)
     {
         owner.remainingActions -= 1;
     }
     else
     {
         owner.remainingMove = 0;
     }
     Initiative.queuedActions++;
     Initiative.EndAction();
 }
示例#4
0
 private void Update()
 {
     //dodging
     if (dodging)
     {
         if (Vector3.Distance(transform.position, dodgeTarget) >= 0.2f)
         {
             transform.position = Vector3.MoveTowards(transform.position, dodgeTarget, Time.deltaTime * 5f);
         }
         else
         {
             transform.position = dodgeTarget;
             dodging            = false;
             AllocateTile();
             Initiative.EndAction();
         }
     }
 }
示例#5
0
    public override void ExecuteAction(ActionCost actionCost)
    {
        Initiative.queuedActions++;
        actioningUnit.gameObject.GetComponent <UnitPopUpManager>().AddPopUpInfo("defending");

        if (actioningUnit.GetComponent <Defending>() == null)
        {
            Defending defending = actioningUnit.gameObject.AddComponent <Defending>();
            defending.AddEffect(actioningUnit.gameObject);
        }
        else if (!actioningUnit.GetComponent <Defending>().enabled)
        {
            actioningUnit.GetComponent <Defending>().enabled = true;
            actioningUnit.GetComponent <Defending>().AddEffect(actioningUnit.gameObject);
        }

        actioningUnit.GetComponent <TacticsMovement>().remainingActions -= 1;
        Initiative.EndAction();
    }
示例#6
0
    public override void ExecuteAction(ActionCost actionCost)
    {
        Initiative.queuedActions++;
        //DamagePopUp.Create(actioningUnit.transform.position + new Vector3(0, (actioningUnit.gameObject.GetComponent<TacticsMovement>().halfHeight) + 0.5f), "Attack Primed", false);
        actioningUnit.gameObject.GetComponent <UnitPopUpManager>().AddPopUpInfo("attack primed");

        if (actioningUnit.GetComponent <Priming>() == null)
        {
            Priming priming = actioningUnit.gameObject.AddComponent <Priming>();
            priming.AddEffect(actioningUnit.gameObject);
        }
        else if (!actioningUnit.GetComponent <Priming>().enabled)
        {
            actioningUnit.GetComponent <Priming>().enabled = true;
            actioningUnit.GetComponent <Priming>().AddEffect(actioningUnit.gameObject);
        }

        actioningUnit.GetComponent <TacticsMovement>().remainingActions -= 1;
        Initiative.EndAction();
    }
示例#7
0
 public void EndAction()
 {
     Initiative.EndAction();
 }
示例#8
0
    public void Move()
    {
        if (!moveGate)
        {
            return;
        }
        else if (path.Count > 0)
        {
            Tile t = path.Peek();

            //Here is my part which establishes the current tiles, and those occupants of those tiles.
            currentTile.occupant = null;
            t.occupant           = this;
            currentTile          = t;

            Vector3 target = t.transform.position;

            //Calculate the unit's position on top of target tile.
            target.y += /*halfHeight  + */ t.GetComponent <Collider>().bounds.extents.y + 0.02f;

            //Failsafe I've put in to catch unit's who's movement has gone wrong
            if (Vector3.Distance(transform.position, target) >= 1.6f)
            {
                transform.position = target;
            }

            if (Vector3.Distance(transform.position, target) >= 0.2f)
            {
                bool jump = false;

                //This next line was...
                //bool jump = transform.position.y != target.y;

                if (transform.position.y >= target.y + 0.05 || transform.position.y <= target.y - 0.05)
                {
                    jump = true;
                }

                if (jump)
                {
                    Jump(target);
                }
                else
                {
                    CalculateHeading(target);
                    SetHorizontalVelocity();
                }

                //Locomotion (and where we would add animation).

                //The following replaces "transform.position += velocity * Time.deltaTime"
                transform.forward = heading;
                if (movingEdge)
                {
                    transform.position = Vector3.MoveTowards(transform.position, jumpTarget, moveSpeed * Time.deltaTime);
                }
                else
                {
                    transform.position += velocity * Time.deltaTime;
                }
            }
            else
            {
                //Tile centre reached
                transform.position = target;

                OnEnterSquare(this); //Alert that a unit has entered a square.

                //Take this move off remaining move IF it's not the first tile in the path.
                if (path.Peek() != firstTileInPath)
                {
                    if (t.diagonal)
                    {
                        if (t.difficultTerrain)
                        {
                            remainingMove -= 2.8f;
                        }
                        else
                        {
                            remainingMove -= 1.41f;
                        }
                    }
                    else
                    {
                        if (t.difficultTerrain)
                        {
                            remainingMove -= 2f;
                        }
                        else
                        {
                            remainingMove--;
                        }
                    }
                }
                path.Pop();
            }
        }
        else
        {
            RemoveSelectableTiles();

            if (focus != null)
            {
                if (RangeFinder.LineOfSight(this, focus) == true)
                {
                    FaceDirection(focus.transform.position);
                }
            }

            if (turnRequired)
            {
                FaceDirection(tileToFace);
                turnRequired = false;
            }
            moving = false;
            unitAnim.SetBool("moving", false);
            moveGate = false;
            Initiative.EndAction();
        }
    }