Beispiel #1
0
    public void BeginTurn()
    {
        GetCurrentTile();
        SelectableTiles.Clear();
        AttackableTiles.Clear();
        GetSelectableTiles();
        GetAttackableTiles();
        HasMoved    = false;
        Turn        = true;
        HasAttacked = false;

        Transform indicator = transform.Find("Indicator/Cylinder");
        Transform effect    = transform.Find("Indicator/Cylinder/Sparkles");

        indicator.localScale = new Vector3(0.25f, 0.25f, 0.25f);
        effect.localScale    = new Vector3(0.3f, 0.3f, 0.3f);
    }
Beispiel #2
0
    void Start()
    {
        this.HasMoved = false;
        TurnManager.Instance.AddUnit(this);

        MoveStart();
        // GetCurrentTile();

        GetCurrentTile();
        SelectableTiles.Clear();
        AttackableTiles.Clear();
        SelectableTiles.FindAvailableTiles(MoveDistance, CurrentTile, JumpHeight, Tiles);
        GetAttackableTiles();
        HasMoved    = false;
        Turn        = true;
        HasAttacked = false;
        // ShowEveryOption();
        // HideEverything();
    }
Beispiel #3
0
    // public void ComputeAdjacencyLists()
    // {
    //  foreach(GameObject tile in Tiles)
    //  {
    //      Tile t = tile.GetComponent<Tile>();
    //      t.FindNeighbors(JumpHeight);
    //  }
    // }

    // public void FindSelectableTiles()
    // {
    //  // ComputeAdjacencyLists();
    //  GetCurrentTile();

    //  Queue<Tile> process = new Queue<Tile>();

    //  process.Enqueue(CurrentTile);
    //  CurrentTile.Visited = true;

    //  while(process.Count > 0)
    //  {
    //      Tile t = process.Dequeue();

    //      SelectableTiles.Add(t);
    //      t.Selectable = true;

    //      if(t.Distance < MoveDistance)
    //      {
    //          foreach(Tile tile in t.AdjacencyList)
    //          {
    //              if(!tile.Visited)
    //              {
    //                  tile.Parent = t;
    //                  tile.Visited = true;
    //                  tile.Distance = 1 + t.Distance;
    //                  process.Enqueue(tile);
    //              }
    //          }
    //      }
    //  }
    // }

    public void Move()
    {
        if (Path.Count > 0)
        {
            Tile    t      = Path.Peek();
            Vector3 target = t.transform.position;

            target.y += HalfHeight + t.GetComponent <Collider>().bounds.extents.y;

            if (Vector3.Distance(transform.position, target) >= 0.05f)
            {
                bool jump = transform.position.y != target.y;
                if (jump)
                {
                    Jump(target);
                }
                else
                {
                    CalculateHeading(target);
                    SetHorizontalVelocity();
                }

                // Add animations here too
                transform.forward   = heading;
                transform.position += velocity * Time.deltaTime;
            }
            else
            {
                transform.position = target;
                Path.Pop();
            }
        }
        else
        {
            RemoveSelectableTiles();
            Moving   = false;
            HasMoved = true;
            GetCurrentTile();
            AttackableTiles.Clear();
            // TurnManager.EndTurn();
        }
    }