Beispiel #1
0
    public IEnumerator Travel()
    {
        UnitScript voyagerUnitScript = voyager.GetComponent <UnitScript>();

        //sanity check
        if (voyagerUnitScript == null)
        {
            Debug.LogError("Why the f**k is there no UnitScript on this Voyager??");
            Log.SpawnLog("ERROR! MoveExe line22");
            yield return(null);
        }
        else if (voyager is UnitFlight)
        {
            Debug.LogError("Travel used instead of fly! Why?");
            Log.SpawnLog("ERROR! MoveExe line30");
            yield return(null);
        }

        else
        //we generally HAVE TO end up here
        {
            SetTileAndUnitPair(voyager.GetComponent <UnitScript>(), path[path.Count - 1]); //basically tells FINAL tile of the path and unit 'you are now married'.
            voyager.CanMove  = false;                                                      // player cannot move it now
            voyager.isMoving = true;                                                       //mostly so that you cannot use an ability on this unit untill it stops moving

            for (int i = 0; i < path.Count; i++)
            {
                voyager.SetDestination(path[i]);
                PathCreator.Instance.ClearPath();
                yield return(new WaitUntil(voyager.HasStoppedMoving));
            }

            FinishMovement(voyager);
        }
    }
Beispiel #2
0
 bool IsTileLegal(int i, int j, UnitMovement unit, bool isAffectedByCombat)
 {
     return
         (Distances[i, j] <= unit.GetCurrentMoveSpeed(!isAffectedByCombat) &&
          Distances[i, j] != -1 &&
          Map.Board[i, j].isWalkable == true &&
          Map.Board[i, j].hasObstacle == false &&
          Map.Board[i, j].myUnit == null &&
          Map.Board[i, j] != unit.GetComponent <UnitScript>().myTile &&
          (EnemyOccupations[i, j] == false || unit.GetComponent <UnitScript>().CheckIfIsInCombat() == false || isAffectedByCombat == false));
 }
    void Atack()
    {
        Vector3 distance = new Vector3();

        distance = target.transform.position - transform.position;

        //if (Mathf.Abs(distance.magnitude) > 1)
        //{
        //    target.GetComponent<BaseStats>().HP -= this.GetComponent<BaseStats>().RangeAtack;
        //    alredyAttack = true;
        //}
        if (Mathf.Abs(distance.magnitude) < 3)
        {
            target.GetComponent <BaseStats>().HP -= this.GetComponent <BaseStats>().MeleAtack;
            ZombieAnimaController.isBiting        = true;
            alredyAttack = true;
        }

        UnitMovement unit = target.GetComponent <UnitMovement>();

        if (unit.GetComponent <BaseStats>().HP <= 0)
        {
            UnitIsAlive(unit);
        }
        else if (alredyAttack)
        {
            unit.gameObject.GetComponentInChildren <CharacterAnimatorController>().lateHitAnimation = true;
        }
    }
Beispiel #4
0
    private void AttackEnemy(RaycastHit hit)
    {
        Vector3 distance = new Vector3();

        distance = hit.collider.transform.position - transform.position;
        if (Mathf.Abs(distance.magnitude) <= this.GetComponent <FieldOfView>().viewRadius)
        {
            if (Mathf.Abs(distance.magnitude) >= 3)
            {
                Weapon.setGunVisible(true);
                hit.collider.GetComponent <BaseStats>().HP -= this.GetComponent <BaseStats>().RangeAtack;
                CharacterAnimController.isShooting          = true;
            }
            else if (Mathf.Abs(distance.magnitude) < 3)
            {
                hit.collider.GetComponent <BaseStats>().HP -= this.GetComponent <BaseStats>().MeleAtack;
                CharacterAnimController.isPunching          = true;
            }

            alredyAttack = true;
        }

        UnitMovement unit = hit.collider.GetComponent <UnitMovement>();

        if (unit.GetComponent <BaseStats>().HP <= 0)
        {
            RingSelectedEnemy.SetDeactiveRing();
            UnitIsAlive(unit);
        }
        else if (alredyAttack)
        {
            unit.GetComponentInChildren <ZombieAnimatorController>().lateHitAnimation = true;
        }
    }
Beispiel #5
0
 public void ColourPossibleTiles(UnitMovement unit, bool notQuittingCombat)
 {
     BFS(unit.GetComponent <UnitScript>().myTile, true);
     //TileColouringTool.UncolourAllTiles();
     //Debug.LogError(unit + " " + colourRed);
     for (int i = 0; i < Map.mapWidth; i++)
     {
         for (int j = 0; j < Map.mapHeight; j++)
         {
             if (Distances[i, j] <= unit.GetCurrentMoveSpeed(notQuittingCombat) && Distances[i, j] != -1)
             {
                 if (notQuittingCombat || EnemyOccupations[i, j] == false)
                 {
                     Map.Board[i, j].TCTool.ColourTileFor(unit.GetComponent <UnitScript>());
                 }
             }
         }
     }
 }
Beispiel #6
0
 bool IsThisTileLegal(Tile tile, UnitMovement unit, bool isAffectedByCombat)
 {
     Pathfinder.Instance.BFS(unit.GetComponent <UnitScript>().myTile, true);
     if (Pathfinder.Instance.GetAllLegalTilesAndIfTheyAreSafe(unit, isAffectedByCombat).ContainsKey(tile))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #7
0
    void SetMovementRelatedData(UnitMovement unitMovement)
    {
        unitMovement.isMoving = false;

        UnitScript unitScript = unitMovement.GetComponent <UnitScript>();

        if (unitScript.CheckIfIsInCombat())
        {
            unitScript.hasJustArrivedToCombat = true;
        }
        if (unitScript.isQuittingCombat)
        {
            unitScript.isQuittingCombat = false;
        }
    }
Beispiel #8
0
 protected void UnitIsAlive(UnitMovement unit)
 {
     if (unit.GetComponent <BaseStats>().HP <= 0)
     {
         if (unit.tag == "Player")
         {
             unit.GetComponentInChildren <CharacterAnimatorController>().lateDeathAnimation = true;
         }
         if (unit.tag == "NPC")
         {
             unit.GetComponentInChildren <ZombieAnimatorController>().lateDeathAnimation = true;
         }
         TurnManager.RemoveUnit(unit);
     }
 }
Beispiel #9
0
    private void markTileOnPath()
    {
        Quaternion newQuaternion = new Quaternion();

        newQuaternion.eulerAngles = new Vector3(90, 0, 0);

        UnitMovement markedUnit = inputManager.getMarkedUnit();

        if (tilePathFinder.getValue() < markedUnit.GetComponent <UnitController>().getActionPoints())
        {
            GameObject.Instantiate(lightPathSource, tileTransform.position + new Vector3(0, height / 2 + lightDistance, 0), newQuaternion);
        }

        if (tilePathFinder.getPreviousTile() != null)
        {
            tilePathFinder.getPreviousTile().GetComponent <TileSelect>().markTileOnPath();
        }
    }
Beispiel #10
0
 public bool CanUnitMoveAtAll(UnitMovement unit)
 {
     return(unit.CanMove && unit.GetComponent <UnitScript>().IsFrozen == false);
 }