Inheritance: MonoBehaviour
Esempio n. 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;
    }
Esempio n. 2
0
 IEnumerator CheckRangeFinders()
 {
     if (Time.time - lastTime < (1 / monitorFrequency) || !ready)
     {
         yield return(null);
     }
     lastTime = Time.time;
     ready    = false;
     for (int i = 0; i < rangefinders.Length; i++)
     {
         try
         {
             RangeFinder rf = rangefinders[i];
             if (rf.detected)
             {
                 rfs[i].text = string.Format("<color=#008000ff><b>{0}: {1:0.00}</b></color>", rf.gameObject.name, rf.range);
             }
             else
             {
                 rfs[i].text = string.Format("{0}: {1:0.00}", rf.gameObject.name, rf.range);
             }
         }
         catch
         {
             GetWC();
         }
     }
     ready = true;
 }
Esempio n. 3
0
 public static void SetCursor()
 {
     if (TacticsMovement.mousedOverUnit != null)
     {
         UnitMouseOverView.Display(TacticsMovement.mousedOverUnit.GetComponent <TacticsMovement>());
         if (focusBeingSelected)
         {
             if (RangeFinder.LineOfSight(currentUnit, TacticsMovement.mousedOverUnit) == true)
             {
                 Cursor.SetCursor(GameAssets.i.Eye_Cursor, Vector2.zero, CursorMode.Auto);
             }
         }
         else if (Initiative.currentUnit != null)
         {
             if ((Initiative.currentUnit.remainingActions > 0) && (!Initiative.currentUnit.moving))
             {
                 foreach (Weapon.Target target in Initiative.currentUnit.GetComponent <TacticsMovement>().mainWeapon.targets)
                 {
                     if (target.unitTargeted == TacticsMovement.mousedOverUnit)
                     {
                         Cursor.SetCursor(GameAssets.i.Sword_Cursor, Vector2.zero, CursorMode.Auto);
                     }
                 }
             }
         }
         else
         {
             Cursor.SetCursor(default, Vector2.zero, CursorMode.ForceSoftware);
Esempio n. 4
0
    public override void EvaluateCandidates(NPC unit, float weighting = 0)
    {
        if (unit.focus != null)
        {
            Task task = new t_runAway();
            task.target = unit.focus;

            unit.GetComponent <AI>().tasks.Add(task);
        }
        else
        {
            foreach (Unit enemy in Initiative.players)
            {
                Task task = new t_runAway();
                task.value  = 1 / Vector3.Distance(unit.transform.position, enemy.transform.position);
                task.tile   = null;
                task.target = enemy.GetComponent <Unit>();

                //am I outnumbered?
                task.value += RangeFinder.HowOutnumberedAmI(unit) / 10;
                task.value += weighting;

                unit.GetComponent <AI>().tasks.Add(task);
            }
        }
    }
Esempio n. 5
0
/*
 *  Function:   Identifies and gets the vector of a moveable object
 *  Invariants: Object must not be in motion
 */
    void TargetShoot()
    {
        if (targetShootController % 2 == 0)
        {
            //Debug.Log("TargetShoot detected");
            targetShootController++;



            if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out targetSeeker))
            {
                GameObject  rangeFinder = GameObject.Find(targetSeeker.transform.name);
                RangeFinder scriptRF    = rangeFinder.GetComponent <RangeFinder>();

                if (targetSeeker.transform.tag == "Moveable" && scriptRF.isInRange)
                {
                    //Debug.Log(targetSeeker.transform.name);
                    GameObject moveableObject = GameObject.Find(targetSeeker.transform.name);
                    moveableObject.GetComponent <Renderer>().material = lashedMaterial;

                    MoveableItemPosition = targetSeeker.transform.position;
                    Debug.Log(MoveableItemPosition);
                    targetIsSet = true;
                }
            }
        }
    }
Esempio n. 6
0
		/// <summary>
		/// Cycles through players fleets, distributing influence points
		/// within their respective ranges. Then triggers each system to 
		/// calculate if controlling influence has been established
		/// </summary>
		private void CalculateInfluence()
		{
			//Cycle through each Players Fleet, retrieving the range of hexes
			//affected and then giving the ship power to each system as influence
			int count = _gameData.PlayerList.Count;
			for(int ID = 0; ID < count; ID ++)
			{
				Fleet fleet = _gameData.PlayerList[ID].Fleet;
				RangeFinder influenceHexes = _gameData.DataMap.RangeFinder();
				for(int i = 0; i < fleet.Count; i++)
				{
					Ship ship = fleet[i];
					ArrayList hexes = influenceHexes.Find(ship.HexLocation.X,ship.HexLocation.Y,
						ship.Range);
					foreach(DataHex hex in hexes)
					{
						StarSystem system = hex.System;
						if(system != null && system.Type != StarSystem.SystemType.Empty)
						{
								system.AddInfluence(ID,ship.Power);
						}
					}
				}
			}
			for(int i = 0; i < _gameData.SystemList.Count; i++)
			{
				_gameData.SystemList[i].ResolveInfluence();
			}
		}
Esempio n. 7
0
 public override void EvaluateCandidates(NPC unit, float weighting = 0)
 {
     Debug.Log("evaluating candidates.");
     if (unit.focus != null)
     {
         Debug.Log("goblin has a focus.");
         Task task = new t_simpleRangedAttackTask();
         task.taskName = "simple ranged";
         task.target   = unit.focus;
         unit.GetComponent <AI>().tasks.Add(task);
     }
     else
     {
         foreach (Unit enemy in Initiative.players)
         {
             Task task = new t_simpleRangedAttackTask();
             task.taskName = "simple ranged";
             task.value    = 1 / Vector3.Distance(unit.transform.position, enemy.transform.position);
             task.tile     = null;
             task.target   = enemy.GetComponent <Unit>();
             if (!RangeFinder.LineOfSight(unit, enemy.GetComponent <Unit>()))
             {
                 task.value -= 1;
             }
             unit.GetComponent <AI>().tasks.Add(task);
         }
     }
 }
Esempio n. 8
0
    public override void DoTask(NPC unit, Unit targetUnit = null, Tile targetTile = null)
    {
        //find a square to move to that isn't next to an enemy.
        if (unit.remainingMove > 0 && moved == false)
        {
            unit.FindSelectableTiles();
            List <Tile> tiles = RangeFinder.FindTilesNotNextToEnemy(unit, unit.selectableTiles, Factions.players);
            int         roll  = Random.Range(0, tiles.Count);
            if (tiles[roll] != null)
            {
                Initiative.queuedActions++;
                CombatLog.UpdateCombatLog(unit.name + " moves toward opposing faction.");
                unit.MoveToTile(tiles[roll]);
                moved = true;
                return;
            }
        }

        //and defend if able.
        if (unit.remainingActions > 0)
        {
            unit.defend.ExecuteAction(ActionCost.main);
            CombatLog.UpdateCombatLog(unit.name + " defends.");
            flagEndofTurn = true;
            return;
        }

        flagEndofTurn = true;
    }
    public override void EvaluateCandidates(NPC unit, float weighting = 0)
    {
        if (unit.focus != null)
        {
            Task task = new t_aggressiveMeleeAttack();
            task.target = unit.focus;
            unit.GetComponent <AI>().tasks.Add(task);
        }
        else
        {
            foreach (Unit target in Initiative.players)
            {
                //check it can find a route.

                unit.destination = target.gameObject;
                target.GetComponent <TacticsMovement>().GetCurrentTile();
                Tile t = unit.FindPath(target.GetComponent <TacticsMovement>().currentTile);
                unit.destination = null;
                if (t == null)
                {
                    return;
                }

                Task task = new t_aggressiveMeleeAttack();
                task.value  = 1 / Vector3.Distance(unit.transform.position, target.transform.position);
                task.tile   = t;
                task.target = target.GetComponent <Unit>();
                if (!RangeFinder.LineOfSight(unit, target.GetComponent <Unit>()))
                {
                    task.value -= 1;
                }
                unit.GetComponent <AI>().tasks.Add(task);
            }
        }
    }
Esempio n. 10
0
    public override void EvaluateCandidates(NPC unit, float weighting = 0)
    {
        Task task = new t_defend {
            tile = null, value = weighting
        };

        task.taskName = "defend";

        //am I being focused on.
        foreach (Unit enemy in Initiative.players)
        {
            if (enemy.focus == unit)
            {
                task.value += 0.2f;
            }
        }

        //am I flagging?
        if (unit.unitInfo.flagging)
        {
            task.value += 0.1f;
        }

        //am I outnumbered?
        task.value += RangeFinder.HowOutnumberedAmI(unit) / 10;

        unit.GetComponent <AI>().tasks.Add(task);
    }
Esempio n. 11
0
 public void MicroWarp(Transform parent, SpaceObject target)
 {
     if (RangeFinder.CalculateDistance(parent, target) > 50.0f)
     {
         parent.position += parent.right * (RangeFinder.CalculateDistance(parent, target) - 50);
     }
 }
Esempio n. 12
0
 public void MoveShipToTarget(Transform parent, SpaceObject target)
 {
     if (target == null)
     {
         SmoothMoveForward(parent, false);
         return;
     }
     SmoothRotateToTarget(parent, target.transform);
     if (target.GetType() == typeof(Ship))
     {
         SmoothMoveForward(parent, true);
     }
     else
     {
         if (RangeFinder.CalculateDistance(parent, target) > 20)
         {
             SmoothMoveForward(parent, true);
         }
         else
         {
             if (RangeFinder.CalculateDistance(parent, target) < 1)
             {
                 _speed = 0;
             }
             else
             {
                 MoveSlowDownToMinSpeed(parent);
             }
         }
     }
 }
Esempio n. 13
0
 public FindIpAddresses(ICrud context)
 {
     IpRange     = new RangeFinder();
     IpAddresses = new List <string>();
     ScanContext = context; //new ScanAddressContext();
     // ElasticSearchContext
 }
Esempio n. 14
0
        private void UpdateBehaviour()
        {
            if (Time.time > _damagedTime + 1.0f)
            {
                _healthStats.RegenerateShield();
            }
            _movement.MoveShipToTarget(transform, _target);

            if (_target == null)
            {
                return;
            }

            if (_target.GetType() != typeof(Ship))
            {
                return;
            }

            var distanceToTarget = RangeFinder.CalculateDistance(transform, _target);

            if (distanceToTarget > 60)
            {
                return;
            }
            foreach (var turretBehaviour in _turretBehaviours)
            {
                turretBehaviour.SetTarget(_target);
            }
        }
Esempio n. 15
0
 void Start()
 {
     character = GetComponent <Character>();
     RF        = GetComponent <RangeFinder>();
     if (character)
     {
         CharacterPlayerNav = character.GetPlayerNav();
     }
 }
Esempio n. 16
0
    /*
     * Saves to inRange set of nodes that are in range of this action. Then adds to its hexes indicators for users as child objects with different color.
     */

    public override void OnSelect(Character character, Hex hex)
    {
        inRange = RangeFinder.FindNodesInRange(hex.GetComponent <Node>(), range);
        foreach (Node node in inRange)
        {
            Transform indicator = Instantiate(hexPrefab, node.transform, true) as Transform;
            indicator.position = node.transform.position;
            indicator.GetComponent <Renderer>().material = material;
        }
    }
Esempio n. 17
0
    void CheckMouse()
    {
        if (Input.GetMouseButtonUp(0))
        {
            if (!EventSystem.current.IsPointerOverGameObject())
            {
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;
                if (Physics.Raycast(ray, out hit))
                {
                    //Work out if a TacticsMovement has been selected.
                    if (hit.collider.GetComponent <TacticsMovement>() != null)
                    {
                        TacticsMovement UnitClickedOn = hit.collider.GetComponent <TacticsMovement>();

                        if (canFocusSwitch)
                        {
                            if (RangeFinder.LineOfSight(this, UnitClickedOn) == true)
                            {
                                SetFocus(UnitClickedOn);
                                remainingActions = 0;
                                remainingMove    = 0;
                                Initiative.queuedActions++;
                                StartCoroutine(Initiative.CheckForTurnEnd());
                            }
                        }
                        else if (remainingActions > 0)
                        {
                            foreach (Weapon.Target target in mainWeapon.targets)
                            {
                                if (target.unitTargeted == UnitClickedOn)
                                {
                                    Initiative.queuedActions += mainWeapon.weaponData.actionsPerAttack;
                                    mainWeapon.StartCoroutine("Attack", target);
                                    return;
                                }
                            }
                        }
                    }
                    else if (hit.collider.tag == "Tile Select")
                    {
                        Tile t = hit.collider.transform.parent.GetComponent <Tile>();
                        if (t.selectable)
                        {
                            Initiative.queuedActions++;
                            MoveToTile(t);
                            return;
                        }
                    }
                }
            }
        }
    }
Esempio n. 18
0
 protected override void Execute()
 {
     if (_isAdgred || LevelManager.InstancedPlayer == null)
     {
         return;
     }
     if (RangeFinder.CalculateDistance(transform, LevelManager.InstancedPlayer) < 100)
     {
         _botsShip.SetTarget(LevelManager.InstancedPlayer);
         _isAdgred = true;
     }
 }
Esempio n. 19
0
        private static string get_nmap_ip_range(string startIP, string endIP)
        {
            string range = string.Empty;

            IEnumerable <string> ipRanges = new RangeFinder().GetIPRange(IPAddress.Parse(startIP), IPAddress.Parse(endIP));

            foreach (var ip in ipRanges)
            {
                range = $"{range}{ip} ";
            }

            return(range);
        }
Esempio n. 20
0
    public override void DoTask(NPC unit, Unit targetUnit = null, Tile targetTile = null)
    {
        //Attack the target if possible.
        if (unit.remainingActions > 0)
        {
            //unit.FindAdjacentUnits();
            RangeFinder.FindAdjacentUnits(unit);
            if (target != null)
            {
                if (unit.adjacentUnits.Contains(target))
                {
                    foreach (Weapon.Target t in unit.mainWeapon.targets)
                    {
                        if (t.unitTargeted == target)
                        {
                            Initiative.queuedActions += 1;
                            unit.mainWeapon.StartCoroutine("Attack", t);
                            CombatLog.UpdateCombatLog(unit.name + " melee attacks " + target.name);
                            flagEndofTurn = true;
                            return;
                        }
                    }
                }
            }
        }

        //Dash if that's needed
        Tile tileToAttackFrom = RangeFinder.FindTileNextToTarget(unit, target.GetComponent <TacticsMovement>());

        if (tileToAttackFrom == null)
        {
            if (unit.remainingActions > 0)
            {
                unit.dash.ExecuteAction(ActionCost.main);
                CombatLog.UpdateCombatLog(unit.name + " dashes.");
                dashed = true;
            }
        }

        //Move closer to the target if needed.
        if ((unit.remainingMove > 0 && unit.remainingActions > 0) || dashed == true)
        {
            unit.destination = target.gameObject;
            CombatLog.UpdateCombatLog(unit.name + " A* toward opposing faction.");
            dashed = false;
        }
        else
        {
            flagEndofTurn = true;
        }
    }
Esempio n. 21
0
    public override IEnumerator Attack(Target target)
    {
        targets.Clear();
        currentTarget = target;
        owner.remainingActions--;

        //Find out what is adjacent to the target.
        RangeFinder.FindAdjacentUnits(currentTarget.unitTargeted);
        bool adjacent = false;

        foreach (Unit _unit in currentTarget.unitTargeted.adjacentUnits)
        {
            if (_unit == owner)
            {
                adjacent = true;
            }
        }

        if (adjacent)
        {
            owner.GetComponent <TacticsMovement>().FaceDirection(currentTarget.unitTargeted.gameObject.transform.position);
        }
        else
        {
            Initiative.queuedActions++;
            owner.MoveToTile(currentTarget.tileToAttackFrom, currentTarget.unitTargeted.currentTile.transform.position);
        }

        yield return(new WaitUntil(() => !owner.moving));

        //See if any of the adjacent units to the target allow you to flank.
        foreach (Unit unit in currentTarget.unitTargeted.adjacentUnits)
        {
            if (unit.unitInfo.faction != currentTarget.unitTargeted.unitInfo.faction)
            {
                Vector3 relTargetPosition        = transform.InverseTransformPoint(currentTarget.unitTargeted.transform.position);
                Vector3 relOtherAttackerPosition = transform.InverseTransformPoint(unit.transform.position);
                if (relOtherAttackerPosition.z > (relTargetPosition.z + 0.1f))
                {
                    flanking = true;
                    break;
                }
            }
        }

        owner.unitAnim.SetTrigger("melee");
        yield break;
    }
Esempio n. 22
0
        private void UpdateSpring()
        {
            _canvasRotator.transform.eulerAngles = new Vector3(0, 0, 0);
            var distanceToTarget = RangeFinder.CalculateDistance(transform, _target);

            if (distanceToTarget < 17.5f)
            {
                _toTargetSpring.transform.localPosition = new Vector3(distanceToTarget, 0, 0);
                _arrowCollider.transform.localPosition  = new Vector3(0, 4, 0);
            }
            else
            {
                _toTargetSpring.transform.localPosition = new Vector3(17.5f, 0, 0);
                _arrowCollider.transform.localPosition  = new Vector3(0, 0, 0);
            }
        }
Esempio n. 23
0
    public override void DoTask(NPC unit, Unit targetUnit = null, Tile targetTile = null)
    {
        //Attack the target if possible.
        if (unit.remainingActions > 0)
        {
            RangeFinder.FindAdjacentUnits(unit);
            if (target != null)
            {
                if (unit.adjacentUnits.Contains(target))
                {
                    foreach (Weapon.Target t in unit.mainWeapon.targets)
                    {
                        if (t.unitTargeted == target)
                        {
                            Initiative.queuedActions++;
                            CombatLog.UpdateCombatLog(unit.name + " melee attacks " + target.name);
                            unit.mainWeapon.StartCoroutine("Attack", t);
                            flagEndofTurn = true;
                            return;
                        }
                    }
                }
            }
        }

        //Move closer to the target if needed.
        if (unit.remainingMove > 0 && unit.remainingActions > 0)
        {
            if (!movedCloser)
            {
                unit.destination = target.gameObject;
                CombatLog.UpdateCombatLog(unit.name + " A* toward opposing faction.");
                movedCloser = true;
                return;
            }
        }

        //Defend if you've not reached the target
        if (unit.remainingActions > 0)
        {
            CombatLog.UpdateCombatLog(unit.name + " defends.");
            unit.defend.ExecuteAction(ActionCost.main);
            return;
        }

        flagEndofTurn = true;
    }
Esempio n. 24
0
    //This needs to set the defence and the defence type.
    static void DecideDefence(Unit attacker, Unit defender)
    {
        defence = defender.unitInfo.currentDefence;

        if (defender.defenceType == DefenceType.BLOCK)
        {
            if (defender.GetComponent <Shield>() != null)
            {
                defenceType     = DefenceType.SHIELD;
                struckAnimation = StruckAnimation.SHIELD;
                ShieldData data = (ShieldData)defender.GetComponent <Shield>().itemData;
                defence += data.shieldModifier;
                return;
            }
            else
            {
                if (defender.GetComponent <MeleeWeapon>() != null)
                {
                    if (defender.GetComponent <MeleeWeapon>().weaponData.weight > ItemData.Weight.light)
                    {
                        if (attacker.mainWeapon.weaponData.rangeType != WeaponData.Range.ranged)
                        {
                            defenceType     = DefenceType.BLOCK;
                            struckAnimation = StruckAnimation.BLOCK;
                            //block anim.
                            return;
                        }
                    }
                }
            }
        }
        if (defender.defenceType != DefenceType.EXPOSED)
        {
            //is there a square to dodge to?
            Tile dodgeTile = RangeFinder.FindTileToDodgeTo(defender.GetComponent <TacticsMovement>(), attacker, RangeFinder.FindDirection(defender.gameObject.transform, attacker.gameObject.transform));
            if (dodgeTile != null)
            {
                float heightOffset = dodgeTile.transform.position.y - defender.GetComponent <TacticsMovement>().currentTile.transform.position.y;
                defender.GetComponent <TacticsMovement>().dodgeTarget = new Vector3(dodgeTile.gameObject.transform.position.x, defender.transform.position.y + heightOffset, dodgeTile.gameObject.transform.position.z);
                defenceType = DefenceType.DODGE;
                return;
            }
        }
        //This catchall currently treats everything that doesn't fit the above as exposed.
        bonuses++;
        defenceType = DefenceType.EXPOSED;
    }
Esempio n. 25
0
    private void Start()
    {
        //Go through each direction and add the neighbour
        for (int point = 0; point < 8; point++)
        {
            neighbours[point] = GetNeighbour(point);
        }

        //Debug
        if (test)
        {
            for (int point = 0; point < 8; point++)
            {
                Debug.Log("Neighbour at " + point + ", is at direction " + RangeFinder.FindDirection(transform, neighbours[point].tile.transform) + " according to rangefinder");
            }
        }
    }
Esempio n. 26
0
    //this bool is used to decide if the action is avialable to the player or not.
    public override bool CheckAvailable()
    {
        if (actioningUnit.GetComponent <Priming>() != null)
        {
            if (actioningUnit.GetComponent <Priming>().enabled == true)
            {
                return(false);
            }
        }

        if (actioningUnit.focus == null)
        {
            return(false);
        }
        if (!RangeFinder.LineOfSight(actioningUnit, actioningUnit.focus))
        {
            return(false);
        }

        if (actioningUnit.mainWeapon.weaponData.rangeType == WeaponData.Range.ranged)
        {
            RangedWeaponData rangedWeapon = actioningUnit.GetComponent <RangedWeapon>().rangedWeaponData;
            if (rangedWeapon.currentAmmo <= 0)
            {
                return(false);
            }
        }
        else if (actioningUnit.mainWeapon.weaponData.rangeType == WeaponData.Range.melee && actioningUnit.mainWeapon.weaponData.weight >= ItemData.Weight.medium)
        {
        }
        else
        {
            return(false);
        }

        if (actioningUnit.unitInfo.currentBreath > 0)
        {
            return(true);
        }

        else
        {
            return(false);
        }
    }
Esempio n. 27
0
 public override void RemovalCheck(Unit unit = null)
 {
     if (blessingUnit != null)
     {
         if (RangeFinder.LineOfSight(owner, blessingUnit))
         {
             return;
         }
         else
         {
             Remove();
         }
     }
     else
     {
         Remove();
     }
 }
Esempio n. 28
0
    public override void GetTargets()
    {
        targets.Clear();
        if (rangedWeaponData.currentAmmo == 0)
        {
            return;
        }

        foreach (TacticsMovement unit in Initiative.order)
        {
            if (unit != owner.GetComponent <TacticsMovement>())
            {
                if (RangeFinder.LineOfSight(owner, unit))
                {
                    AddTarget(unit, owner.currentTile);;
                }
            }
        }
    }
Esempio n. 29
0
    public override void EvaluateCandidates(NPC unit, float weighting = 0)
    {
        foreach (Unit u in Initiative.players)
        {
            //check it can find a route.

            unit.destination = u.gameObject;
            u.GetComponent <TacticsMovement>().GetCurrentTile();
            Tile t = unit.FindPath(u.GetComponent <TacticsMovement>().currentTile);
            unit.destination = null;
            attacked         = false;
            if (t == null)
            {
                return;
            }

            Task task = new t_sneakyMeleeAttack();
            task.value  = 1 / Vector3.Distance(unit.transform.position, u.transform.position);
            task.tile   = t;
            task.target = u.GetComponent <Unit>();

            if (!RangeFinder.LineOfSight(unit, u.GetComponent <Unit>()))
            {
                task.value -= 1;
            }
            //Debug
            if (unit.focus == u)
            {
                task.value += 10f;
            }
            //if (unit.focus == u) task.value += 0.4f;
            if (u.focus == unit)
            {
                task.value -= 0.3f;
            }
            if (RangeFinder.FindFlankingTile(unit, unit.selectableTiles, u.GetComponent <TacticsMovement>()) != null)
            {
                task.value += 0.2f;
            }

            unit.GetComponent <AI>().tasks.Add(task);
        }
    }
Esempio n. 30
0
    private void FixedUpdate()
    {
        //if (!turn)
        if (Initiative.currentUnit != this)
        {
            if (focus != null)
            {
                if (RangeFinder.LineOfSight(this, focus) == true)
                {
                    FaceDirection(focus.transform.position);
                }
            }
        }
        else
        {
            if (!moving && Initiative.queuedActions < 1)
            {
                destination = null;
                ai.DoTurn();

                //This section DOES the A* move, but once the tile has been decided.
                if (remainingMove >= 1 && turn && destination != null)
                {
                    CalculatePath();

                    //Failsafe, in case of there being no path.
                    if (actualTargetTile == null)
                    {
                        ai.task = new DefaultTask();
                        Debug.LogWarning("unit defaulted on task as no route found.");
                        return;
                    }

                    NPCMove();
                    actualTargetTile.target = true;
                }
            }
            else
            {
                Move();
            }
        }
    }