// Update is called once per frame
 void Update()
 {
     foreach (Vector3 point in Formations.GetPolygonFormation(leader.position, center.position, normal.position - center.position, numberOfSides, amount))
     {
         Debug.DrawLine(center.position, point, Color.red);
     }
     foreach (Vector3 point in Formations.GetCircleFormation(leader.position, center.position, normal.position - center.position, amount))
     {
         Debug.DrawLine(center.position, point, Color.blue);
     }
 }
Esempio n. 2
0
    void Awake()
    {
        Fsm = new StateMachine <Enemy>(this);
        State <Enemy> state;

        switch (this.startState)
        {
        case StartState.Wander:
            state = new DumbWanderState(this, Fsm, 30.0f);
            break;

        case StartState.ReachGoal:
            state = new ReachGoalState(this, Fsm, target);
            break;

        default:
            state = new DumbWanderState(this, Fsm, 30.0f);
            break;
        }
        Fsm.InitialState(state);

        GroupPositions = new List <GameObject>(GroupMembers.Count);
        switch (this.formation)
        {
        case Formation.V:
            generatePositions(Formations.GetVFormation(this.transform.position, spread, GroupMembers.Count));
            break;

        case Formation.Circle:
            generatePositions(Formations.GetCircleFormation(this.transform.position + spread * (new Vector3(1, 0, 0)), this.transform.position, new Vector3(0, 1, 0), GroupMembers.Count));
            break;

        case Formation.Square:
            generatePositions(Formations.GetPolygonFormation(this.transform.position + spread * (new Vector3(1, 0, 0)), this.transform.position, new Vector3(0, 1, 0), 4, GroupMembers.Count));
            break;

        case Formation.Triangle:
            generatePositions(Formations.GetPolygonFormation(this.transform.position + spread * (new Vector3(1, 0, 0)), this.transform.position, new Vector3(0, 1, 0), 3, GroupMembers.Count));
            break;

        case Formation.Polygon:
            if (formationSideCount > 3)
            {
                generatePositions(Formations.GetPolygonFormation(this.transform.position + spread * (new Vector3(1, 0, 0)), this.transform.position, new Vector3(0, 1, 0), formationSideCount, GroupMembers.Count));
            }
            break;
        }
    }