예제 #1
0
 private void Start()
 {
     this.hexGrid.Centre.Inhabit(this.playerPartyActor);
     //this.playerPartyActor.InhabitedNode = this.hexGrid.Centre;
     this.hexGrid.Centre.inhabitingActor      = playerPartyActor;
     this.playerPartyActor.transform.position = hexGrid.Centre.gameObject.transform.position;
     this.playerPartyActor.GetComponent <Engine.Actions.ActionQueue>().AddToFront(MoveToNode.CreateComponent(this.playerPartyActor.gameObject, this.hexGrid.Centre, this.hexGrid.Centre));
 }
예제 #2
0
        public void MoveToTile(HexTile tile)
        {
            if (tile == null)
            {
                Debug.Log("A collider was detected that wasn't a tile! Is there a configuration issue?");
                return;
            }

            Debug.DrawLine(actor.transform.position, tile.transform.position);
            actor.InhabitedNode.gameObject.layer = LayerMask.NameToLayer("Ignore Raycast");
            var hit = Physics2D.Linecast(actor.transform.position, tile.transform.position, 1 << LayerMask.NameToLayer("Traversable"));

            actor.InhabitedNode.gameObject.layer = LayerMask.NameToLayer("Traversable");

            if (hit.collider != null)
            {
                HexTile nearestTile = hit.collider.gameObject.GetComponent <HexTile>();

                if (tile != null)
                {
                    this.actor.GetComponent <Engine.Actions.ActionQueue>().AddToFront(MoveToNode.CreateComponent(this.actor.gameObject, this.actor.InhabitedNode, nearestTile));
                }
            }
        }