Beispiel #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     size              = (int)numericUpDown1.Value;
     myboard           = new board(size);
     label2.Text       = size.ToString();
     myTiles           = myboard.getTiles();
     tilecount.Text    = myTiles.Count.ToString();
     pictureBox1.Image = HexMaker.MakeThat(size);
 }
Beispiel #2
0
    public void GetPath()
    {
        switch (_currentState)
        {
        case State.Idle:
        case State.Guard:
        case State.Dead:
            break;

        case State.Wander:
            TryGetRandomPos(_creature.MaxCanMoveDist);
            break;

        case State.Patrol:
            if (_waypoints.Length == 0)
            {
                Debug.LogWarning($"{_creature.Name}'s AI is set to Patrol, but it doesn't have any waypoints.",
                                 this);
                return;
            }

            if (_currentWaypoint < _waypoints.Length - 1)
            {
                _currentWaypoint++;
            }
            else
            {
                _currentWaypoint = 0;
            }

            HexMaker.Instance.GetDistanceToCoord(_creature.Coord, HexMaker.GetCoord(_waypoints[_currentWaypoint]),
                                                 _creature.TargetPath);
            break;

        case State.Chase:
            if (_targetCreature == null)
            {
                Debug.LogWarning("Trying to run from, nothing?", this);
                break;
            }

            HexMaker.Instance.GetDistanceToCoord(_creature.Coord, _targetCreature.Coord, _creature.TargetPath);
            break;

        case State.Fleeing:
            if (_targetCreature == null)
            {
                Debug.LogWarning($"{_creature.Name} is trying to flee but has to Target Creature", this);
                return;
            }

            TryGetFleePos();
            break;
        }
    }
Beispiel #3
0
    private void Awake()
    {
        if (!Application.isPlaying)
        {
            return;
        }

        if (enabled && Instance == null)
        {
            Instance = this;
        }
        else
        {
            Destroy(this);
        }
    }
Beispiel #4
0
    private static Coordinates GetSequentialNeighbors(Coordinates startingPoint, HexDir direction,
                                                      List <Coordinates> coords,
                                                      int dist, bool shouldAdd = true)
    {
        var         neighbor      = startingPoint.GetNeighbor((int)direction);
        Coordinates neighborCoord = null;

        for (var i = 0; i < dist; i++)
        {
            neighborCoord = HexMaker.GetCoord(neighbor.index);
            if (neighborCoord != null)
            {
                if (neighborCoord.IsWalkable)
                {
                    coords.Add(neighborCoord);
                }

                neighbor = neighborCoord.GetNeighbor((int)direction);
            }
        }

        return(neighborCoord);
    }