예제 #1
0
        public List <ATTile> TilesWithinRange(int range)
        {
            List <ATTile> tiles = new List <ATTile> ();


            Vector3 bottomLeftOfRange = new Vector3(transform.position.x - range, transform.position.y - range);
            int     checks            = (range * 2) + 1;

            for (int i = 0; i < checks; i++)
            {
                for (int j = 0; j < checks; j++)
                {
                    ATTile prospect = MapManager.instance.TileAt(bottomLeftOfRange + new Vector3(i, j, transform.position.z));
                    if (prospect == null || prospect.overriddenAsNotWalkable || prospect == this || prospect.HCostTo(this) > range)
                    {
                        //Debug.Log ("prospect is null");
                        continue;
                    }


                    tiles.Add(prospect);
                }
            }
            return(tiles);
        }
예제 #2
0
        void ATTile_OnOccupantRemoved(TileMovement occ, ATTile destination)
        {
            if (IsDifficultTerrain)
            {
                stumblingOcc.Remove(occ);
                occ.ActorComponent.CharSheet.OnAboutToAttack     -= CursedWillPerform;
                occ.ActorComponent.CharSheet.OnAboutToBeAttacked -= CursedWillBeAttacked;
//				Debug.LogError ("bla bla");
            }

            //have actors that can see this tile unsee the actor that was removed if they can't see the destination tile and can see enemy.
            foreach (Actor act in actorsThatSeeThisTile)
            {
                Vision eyes = act.GetComponent <Vision> ();
                if (eyes.CanSee(occ.ActorComponent) && act != occ.ActorComponent)
                {
                    if (destination == null)                       //the actor probably died.
                    {
                        Debug.Log("actor: " + eyes.Actor.GetType());
                        eyes.UndiscoverEnemyActor(occ.ActorComponent);
                    }
                    else if (act.EnemiesWith(occ.ActorComponent))
                    {
                        if (!destination.actorsThatSeeThisTile.Contains(act))
                        {
                            eyes.UndiscoverEnemyActor(occ.ActorComponent);
                        }
                    }
                }
            }
        }
예제 #3
0
        public List <ATTile> Neighbors()
        {
            List <ATTile> ret   = new List <ATTile> ();
            ATTile        up    = Up();
            ATTile        down  = Down();
            ATTile        left  = Left();
            ATTile        right = Right();

            if (up != null)
            {
                ret.Add(up);
            }

            if (down != null)
            {
                ret.Add(down);
            }

            if (left != null)
            {
                ret.Add(left);
            }

            if (right != null)
            {
                ret.Add(right);
            }

            return(ret);
        }
    IEnumerator LaunchAfterDelay(float delay, AT.ATTile target, bool noBlockers)
    {
        Debug.Log("Waiting " + delay + " seconds to launch");
        yield return(new WaitForSeconds(delay));

        LaunchAt(target, noBlockers);
    }
예제 #5
0
 public void RemoveOccupant(TileMovement occ, ATTile desitination)
 {
     currentOccupants.Remove(occ);
     occ.ActorComponent.OnActorKilled -= OnDeathOccupantCleanup;
     if (OnOccupantRemoved != null)
     {
         OnOccupantRemoved(occ, desitination);
     }
 }
예제 #6
0
        public void AddOccupant(TileMovement occ, ATTile previous)
        {
            occ.ActorComponent.OnActorKilled += OnDeathOccupantCleanup;
            currentOccupants.Add(occ);

            if (OnOccupantAdded != null)
            {
                OnOccupantAdded(occ, previous);
            }
        }
예제 #7
0
    public void ShowTileProps(AT.ATTile tile)
    {
//		if (tile == lastTile)
//			return;
        //do movement

        DestroyLastCollection();
        gameObject.SetActive(true);
        ActuallyShow(tile);
        //StartCoroutine (ActuallyShow (tile));
    }
예제 #8
0
        public List <ATTile> TracePathTo(ATTile aStarredTarget)
        {
            ATTile        current = aStarredTarget;
            List <ATTile> ret     = new List <ATTile>();

            while (current != this)
            {
                if (current.pathParent == null)
                {
                    return(null);
                }
                ret.Add(current);
                current = current.pathParent;
            }
            ret.Reverse();
            return(ret);
        }
예제 #9
0
        void ATTile_OnOccupantAdded(TileMovement occ, ATTile previous)
        {
            if (IsDifficultTerrain)
            {
                stumblingOcc.Add(occ);
                occ.ActorComponent.CharSheet.OnAboutToAttack     += CursedWillPerform;
                occ.ActorComponent.CharSheet.OnAboutToBeAttacked += CursedWillBeAttacked;
            }

            //have actors that can see this tile discover the actor that was added if they don't already see it.
            foreach (Actor act in actorsThatSeeThisTile)
            {
                if (occ.ActorComponent == act)
                {
                    continue;
                }
                Vision eyes = act.GetComponent <Vision> ();
                if (act.EnemiesWith(occ.ActorComponent) && !eyes.CanSee(occ.ActorComponent))
                {
                    eyes.DiscoverEnemyActor(occ.ActorComponent);
                }
            }
        }
예제 #10
0
    public void ActuallyShow(AT.ATTile tile)
    {
//			destroyedSinceWait = false;


//			yield return new WaitForSeconds (1f);


//			if (!destroyedSinceWait && tile != lastTile) {

        AddTextValue(tile.baseMoveCost.ToString(),
                     IconDispenser.instance.SpriteFromIconName(AT.Character.IconName.MOVE));

        if (tile.IsDifficultTerrain)
        {
            AddImageValue(IconDispenser.instance.SpriteFromIconName(AT.Character.IconName.ARROW_DOWN),
                          IconDispenser.instance.SpriteFromIconName(AT.Character.IconName.MELEE_ATTACK)).GetComponent <Image> ().color = new Color(1f, 0.1f, 0f, .7f);
            AddImageValue(IconDispenser.instance.SpriteFromIconName(AT.Character.IconName.ARROW_DOWN),
                          IconDispenser.instance.SpriteFromIconName(AT.Character.IconName.SHIELD_METAL));
        }
//			}
//			lastTile = tile;
    }
예제 #11
0
 public void ShowOnTile(AT.ATTile tile)
 {
     transform.position = tile.transform.position;
     UIManager.instance.tileInfoPanel.ShowTileProps(tile);
 }
예제 #12
0
 //TODO: Move distance might want to incorporate
 public int HCostTo(ATTile to)
 {
     return((int)Mathf.Round(Mathf.Abs(to.X() - X()) + Mathf.Abs(to.Y() - Y())));
 }
예제 #13
0
 public float DistanceSquared(ATTile to)
 {
     return(Mathf.Pow(to.X() - X(), 2f) +
            Mathf.Pow(to.Y() - Y(), 2f));
 }
 public void DelayLaunchAt(AT.ATTile tTile, float delay, bool noBlockers = false)
 {
     StartCoroutine(LaunchAfterDelay(delay, tTile, noBlockers));
 }
 public void LaunchAt(AT.ATTile tTile, bool noBlockers = false)
 {
     targetTile = tTile;
     LaunchAt(targetTile.transform, noBlockers);
 }