예제 #1
0
    public static void LoadScene(int _sceneId)
    {
        Application.LoadLevel(2);

        // Call All Reset Statics
        PlayerChildFSM.ResetStatics();
        PlayerMain.ResetStatics();
        player_control.ResetStatics();
        GameManager.ResetStatics();
        EndGamePanel.ResetStatics();

        PlayerSquadFSM.ResetStatics();
        SquadChildFSM.ResetStatics();

        Wall.ResetStatics();
        WallRenderer.ResetStatics();
        Nutrients.ResetStatics();

        ECPoolManager.ResetStatics();
        ECIdleState.ResetStatics();
        DirectionDatabase.ResetStatics();
        FormationDatabase.ResetStatics();
        PathQuery.ResetStatics();
        PointDatabase.ResetStatics();
        PositionQuery.ResetStatics();
        ECTracker.ResetStatics();

        EnemyMainFSM.ResetStatics();

        Application.LoadLevel(_sceneId);
    }
예제 #2
0
 void HasAllCellsEnterMain()
 {
     if (ECTracker.s_Instance != null)
     {
         List <EnemyChildFSM> ECList = ECTracker.s_Instance.IdleCells;
         for (int i = 0; i < ECList.Count; i++)
         {
             if (!ECIdleState.HasChildEnterMain(ECList [i].gameObject))
             {
                 bIsAllChildWithinMain = false;
                 return;
             }
         }
         bIsAllChildWithinMain = true;
     }
 }
예제 #3
0
    public override void FixedExecute()
    {
        Vector2 Acceleration = Vector2.zero;

        //Add the velocity of the enemy main cell to let the child cell follow the main cell without falling behind
        Acceleration += m_Main.GetComponent <Rigidbody2D>().velocity;

        //if there is any attacking player cell nearby and there is a closest attacker, add the velocity for the enemy child cell to evade that closest attacker
        if (!m_bReturnToMain && m_AttackersNearby.Count > 0 && m_ClosestAttacker != null && m_ClosestAttacker.attackMode != PlayerAttackMode.SwarmTarget)
        {
            Acceleration += LimitMaxAccelBasedOnHeight(SteeringBehavior.Evade(m_Child, m_ClosestAttacker.gameObject, 24f));
        }
        else if (m_bReturnToMain && !ECIdleState.HasChildEnterMain(m_Child))
        {
            m_ecFSM.rigidbody2D.drag = 1.4f;
            Acceleration            += SteeringBehavior.Seek(m_Child, m_Main.transform.position, 10f);
        }
        else if (m_bReturnToMain && ECIdleState.HasChildEnterMain(m_Child))
        {
            m_ecFSM.rigidbody2D.velocity = Vector2.zero;
            MessageDispatcher.Instance.DispatchMessage(m_Child, m_Child, MessageType.Idle, 0);
        }
        else
        {
            Acceleration += SteeringBehavior.ShakeOnSpot(m_Child, 1f, 8f);
        }

        //Clamp the velocity to a maximum value, so the speed will reach a constant value
        Acceleration = Vector2.ClampMagnitude(Acceleration, m_fMaxAcceleration);

        //Add the calculate force to the enemy child cell to move it
        m_ecFSM.rigidbody2D.AddForce(Acceleration, ForceMode2D.Force);

        //If the enemy child cell is avoiding, rotate the cell to whichever direction it travel. Else, just randomly rotate clockwise and anti-clockwise
        if (Acceleration.magnitude > m_Main.GetComponent <Rigidbody2D>().velocity.magnitude)
        {
            m_ecFSM.RotateToHeading();
        }
        else
        {
            m_ecFSM.RandomRotation();
        }
    }