コード例 #1
0
    // Expand animation in Landmine state
    private void LandmineAnimation()
    {
        if (EnemyMainFSM.Instance().CurrentStateIndex == EMState.Landmine)
        {
            if (bIsExpanding)
            {
                if (currentScale.x <= fTargetSize)
                {
                    currentScale.x += fDefaultExpandRate * fLandmineExpandFactor * Mathf.Sqrt(fTargetSize - currentScale.x);
                    currentScale.y += fDefaultExpandRate * fLandmineExpandFactor * Mathf.Sqrt(fTargetSize - currentScale.y);
                }
                else
                {
                    bIsExpanding = false;
                    bIsShrinking = true;
                }
            }
            else if (!bIsExpanding &&
                     bIsShrinking &&
                     currentScale.x >= initialScale.x * Mathf.Sqrt(Mathf.Sqrt(Mathf.Sqrt(Mathf.Pow((float)EnemyMainFSM.Instance().Health, 1.5f)))))
            {
                currentScale.x -= fDefaultExpandRate * fLandmineExpandFactor * Mathf.Sqrt(Mathf.Abs(fTargetSize - currentScale.x));
                currentScale.y -= fDefaultExpandRate * fLandmineExpandFactor * Mathf.Sqrt(Mathf.Abs(fTargetSize - currentScale.y));
            }
            else if (!bIsExpanding &&
                     bIsShrinking &&
                     currentScale.x < initialScale.x * Mathf.Sqrt(Mathf.Sqrt(Mathf.Sqrt(Mathf.Pow((float)EnemyMainFSM.Instance().Health, 1.5f)))))
            {
                bIsShrinking = false;
                bIsExpanding = true;
            }

            transform.localScale = (Vector3)currentScale;
        }
    }
コード例 #2
0
 // Angular velocity declines faster in Stun state
 private void FasterRotationDecline()
 {
     if (bCanRotate && EnemyMainFSM.Instance().CurrentStateIndex == EMState.Stunned)
     {
         if (fAngularVelocity >= 0f)
         {
             if (fAngularVelocity >= fMinAngularVelocity)
             {
                 fAngularVelocity -= fAngularDeclineFactor * Mathf.Sqrt(Mathf.Abs(fAngularVelocity) * 5f);
             }
         }
         else if (fAngularVelocity < 0f)
         {
             if (fAngularVelocity <= -fMinAngularVelocity)
             {
                 fAngularVelocity += fAngularDeclineFactor * Mathf.Sqrt(Mathf.Abs(fAngularVelocity) * 5f);
             }
         }
         // If the angular velocity is too small, set it to zero
         if (Mathf.Abs(fAngularVelocity) < fMinAngularVelocity / 2f)
         {
             fAngularVelocity = 0f;
         }
     }
 }
コード例 #3
0
 public EMAggressiveAttackState(EnemyMainFSM EMFSM)
 {
     m_EMFSM    = EMFSM;
     transition = m_EMFSM.emTransition;
     controller = m_EMFSM.emController;
     helper     = m_EMFSM.emHelper;
 }
コード例 #4
0
    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }

        // GetComponent
        m_EMFSM  = GetComponent <EnemyMainFSM> ();
        width    = GetComponent <CircleCollider2D> ().bounds.size.x;
        fRadius  = GetComponent <CircleCollider2D> ().bounds.size.x;
        position = transform.position;

        // Find gameObject
        ECPool = GameObject.Find("Enemy Child Cell Pool").GetComponent <ECPoolManager>();

        // Initialise status
        bIsEnemyVisible = true;
        bIsEnemyWin     = false;
        bCanSpawn       = true;
        // Able to command child cells to any state by default
        bCanAddDefend   = true;
        bCanAddAttack   = true;
        bCanAddLandmine = true;
    }
コード例 #5
0
 void Start()
 {
     if (instance == null)
     {
         instance = this;
     }
     // Initialization of difficulty and factors
     fHealthDiff           = 1f;
     fHealthWeight         = 1f;
     fNutrientDiff         = 1f;
     fNutrientWeight       = 1f;
     fLevelDiff            = 1f;
     fLevelWeight          = 1f;
     fCurrentDiff          = 1f;
     fMaxHealthInfluence   = .5f;
     fMaxNutrientInfluence = .5f;
     // Initialization of current health and num of nutrient
     if (EnemyMainFSM.Instance().Health != 0)
     {
         nCurrentHealth = EnemyMainFSM.Instance().Health;
     }
     if (EMController.Instance().NutrientNum != 0)
     {
         nCurrentNutrient = EMController.Instance().NutrientNum;
     }
 }
コード例 #6
0
    public override void Enter()
    {
        if (m_pcFSM.m_formationCells[0] == m_pcFSM)
        {
            m_bIsLeader = true;
        }

        m_bIsLeaderAlive = true;
        m_nLeaderIndex   = 0;
        m_targetPos      = m_pcFSM.transform; // In case leader doesn't process first.

        if (m_pcFSM.attackMode == PlayerAttackMode.ScatterShot)
        {
            m_targetPos = EnemyMainFSM.Instance().transform;
        }

        if (m_pcFSM.attackMode == PlayerAttackMode.SwarmTarget)
        {
            AudioManager.PlayPMSoundEffectNoOverlap(PlayerMainSFX.Swarm);
        }
        else if (m_pcFSM.attackMode == PlayerAttackMode.ScatterShot)
        {
            AudioManager.PlayPMSoundEffectNoOverlap(PlayerMainSFX.ScatterShot);
        }
    }
コード例 #7
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);
    }
コード例 #8
0
    //Extract an Enemy Child Cell from the pool and spawn it to the position given in the perimeter
    public GameObject SpawnFromPool(Vector2 _SpawnPos, bool _Default)
    {
        if (!_Default)
        {
            EMHelper.Instance().StartProduceChild();
        }
        m_nSpawnCount++;

        //Extract the enemy child cell pool from the pool and add it to the enemy child cell list
        if (s_ECPool.Peek() == null)
        {
            return(null);
        }

        GameObject newChild = s_ECPool.Dequeue();

        newChild.transform.position = _SpawnPos;
        MessageDispatcher.Instance.DispatchMessage(this.gameObject, newChild, MessageType.Idle, 0);
        EnemyMainFSM.Instance().ECList.Add(newChild.GetComponent <EnemyChildFSM> ());
        EnemyMainFSM.Instance().AvailableChildNum++;

        if (IsPoolEmpty())
        {
            return(null);
        }

        return(newChild);
    }
コード例 #9
0
    //Constructor
    public ECIdleState(GameObject _childCell, EnemyChildFSM _ecFSM)
    {
        m_Child       = _childCell;
        m_ecFSM       = _ecFSM;
        m_Main        = m_ecFSM.m_EMain;
        m_EMTransform = m_Main.transform;

        m_fMaxMagnitude = 7.5f;
        m_fTimerLimit   = 1.5f;

        m_fSpreadRange = m_Child.GetComponent <SpriteRenderer>().bounds.size.x / 10;
        m_EMControl    = m_Main.GetComponent <EMController>();
        m_EMBounds     = m_Main.GetComponent <SpriteRenderer>().bounds;
        m_EMFSM        = m_Main.GetComponent <EnemyMainFSM>();
        m_ChildRB      = m_Child.GetComponent <Rigidbody2D>();
        m_MainRB       = m_Main.GetComponent <Rigidbody2D>();

        m_Collisions = new Collider2D[m_EMFSM.ECList.Count];
        m_Neighbours = new List <GameObject>();

        m_ecFSM.rigidbody2D.drag = 0f;
        m_nIdleCount             = 0;
        m_CurrentIdleState       = IdleStatus.None;

        m_ShrinkRate = new Vector3(0.025f, -0.025f, 0f);
    }
コード例 #10
0
    //Constructor
    public ECIdleState(GameObject _childCell, EnemyChildFSM _ecFSM)
    {
        m_Child = _childCell;
        m_ecFSM = _ecFSM;
        m_Main = m_ecFSM.m_EMain;
        m_EMTransform = m_Main.transform;

        m_fMaxMagnitude = 7.5f;
        m_fTimerLimit = 1.5f;

        m_fSpreadRange = m_Child.GetComponent<SpriteRenderer>().bounds.size.x/10;
        m_EMControl = m_Main.GetComponent<EMController>();
        m_EMBounds = m_Main.GetComponent<SpriteRenderer>().bounds;
        m_EMFSM = m_Main.GetComponent<EnemyMainFSM>();
        m_ChildRB = m_Child.GetComponent<Rigidbody2D>();
        m_MainRB = m_Main.GetComponent<Rigidbody2D>();

        m_Collisions = new Collider2D[m_EMFSM.ECList.Count];
        m_Neighbours = new List<GameObject>();

        m_ecFSM.rigidbody2D.drag = 0f;
        m_nIdleCount = 0;
        m_CurrentIdleState = IdleStatus.None;

        m_ShrinkRate = new Vector3(0.025f,-0.025f,0f);
    }
コード例 #11
0
    public Nutrients GetNearestResource()
    {
        Nutrients[] nutrientsPool   = Nutrients.playerNutrientPool;
        Nutrients   nearestNutrient = null;

        for (int i = 0; i < nutrientsPool.Length; i++)
        {
            // if: The current nutrients is NOT in the pool and NOT being collected by player
            if (!nutrientsPool[i].IsInPool && nutrientsPool[i].IsCollectable)
            {
                // if: This function only returns nutrients that is below the EnemyMain
                if (nutrientsPool[i].transform.position.y < EnemyMainFSM.Instance().transform.position.y - EnemyMainFSM.Instance().transform.lossyScale.y)
                {
                    // if: Target only nutrients that are middle of the playing field
                    if (Mathf.Abs(nutrientsPool[i].transform.position.x) < 4f)
                    {
                        // if: There is no nearest nutrients yet
                        if (nearestNutrient == null)
                        {
                            nearestNutrient = nutrientsPool[i];
                        }
                        // else if: The checking nutrient is nearer than the curent nearest nutrient
                        else if (Vector3.Distance(nearestNutrient.transform.position, PlayerSquadFSM.Instance.transform.position) > Vector3.Distance(nutrientsPool[i].transform.position, PlayerSquadFSM.Instance.transform.position))
                        {
                            nearestNutrient = nutrientsPool[i];
                        }
                    }
                }
            }
        }

        return(nearestNutrient);
    }
コード例 #12
0
    //constructor
    public ECTrickAttackState(GameObject _childCell, EnemyChildFSM _ecFSM)
    {
        m_Child = _childCell;
        m_ecFSM = _ecFSM;
        m_Main = m_ecFSM.m_EMain;

        m_Nodes = new GameObject[3];
        m_ShrinkRate = new Vector3(-0.225f, 0.225f, 0.0f);
        m_fMaxAcceleration = 40f;

        m_EMFSM = m_Main.GetComponent<EnemyMainFSM>();
        m_Nodes[0] = Node_Manager.GetNode(Node.LeftNode).gameObject;
        m_Nodes[1] = Node_Manager.GetNode(Node.RightNode).gameObject;
        m_SquadCaptain = PlayerSquadFSM.Instance.gameObject;

        BoxCollider2D[] Walls = GameObject.Find("Wall").GetComponents<BoxCollider2D>();
        for(int i = 0 ; i < Walls.Length; i++)
        {
            if(Walls[i].offset.y > 39f && Walls[i].offset.x > 7f)
            {
                m_RightWall = Walls[i];
            }
            else if(Walls[i].offset.y > 39f && Walls[i].offset.x < -7f)
            {
                m_LeftWall = Walls[i];
            }
        }
    }
コード例 #13
0
    //constructor
    public ECTrickAttackState(GameObject _childCell, EnemyChildFSM _ecFSM)
    {
        m_Child = _childCell;
        m_ecFSM = _ecFSM;
        m_Main  = m_ecFSM.m_EMain;

        m_Nodes            = new GameObject[3];
        m_ShrinkRate       = new Vector3(-0.225f, 0.225f, 0.0f);
        m_fMaxAcceleration = 40f;

        m_EMFSM        = m_Main.GetComponent <EnemyMainFSM>();
        m_Nodes[0]     = Node_Manager.GetNode(Node.LeftNode).gameObject;
        m_Nodes[1]     = Node_Manager.GetNode(Node.RightNode).gameObject;
        m_SquadCaptain = PlayerSquadFSM.Instance.gameObject;

        BoxCollider2D[] Walls = GameObject.Find("Wall").GetComponents <BoxCollider2D>();
        for (int i = 0; i < Walls.Length; i++)
        {
            if (Walls[i].offset.y > 39f && Walls[i].offset.x > 7f)
            {
                m_RightWall = Walls[i];
            }
            else if (Walls[i].offset.y > 39f && Walls[i].offset.x < -7f)
            {
                m_LeftWall = Walls[i];
            }
        }
    }
コード例 #14
0
	public EMAggressiveAttackState (EnemyMainFSM EMFSM)
	{
		m_EMFSM = EMFSM;
		transition = m_EMFSM.emTransition;
		controller = m_EMFSM.emController;
		helper = m_EMFSM.emHelper;
	}
コード例 #15
0
    private bool CheckGameEnd()
    {
        if (EnemyMainFSM.Instance() == null ||
            PlayerMain.Instance == null ||
            EMHelper.Instance() == null)
        {
            return(false);
        }

        if (EnemyMainFSM.Instance().CurrentStateIndex == EMState.Die)
        {
            bPlayerWon  = true;
            bGameIsOver = true;
            return(true);
        }
        else if (PlayerMain.Instance.IsAlive == false)
        {
            bPlayerWon  = false;
            bGameIsOver = true;
            return(true);
        }
        else if (EMHelper.Instance().IsEnemyWin == true)
        {
            bPlayerWon  = false;
            bGameIsOver = true;
            return(true);
        }

        return(false);
    }
コード例 #16
0
    private Vector2 GetHeadingDirection()
    {
        Vector2 sumVector = Vector2.zero;

        sumVector.x = EnemyMainFSM.Instance().transform.position.x - m_pcFSM.m_formationCells[0].transform.position.x;
        sumVector.y = EnemyMainFSM.Instance().transform.position.y - m_pcFSM.m_formationCells[0].transform.position.y;
        return(sumVector.normalized);
    }
コード例 #17
0
 // Update health factor
 void HealthDiffUpdate()
 {
     // Max fHealthDiff = 1f + fMaxHealthInfluence
     if (EnemyMainFSM.Instance().Health != 0)
     {
         fHealthDiff = 1f + fMaxHealthInfluence / Mathf.Sqrt(Mathf.Sqrt((float)nCurrentHealth));
     }
 }
コード例 #18
0
 void RegainFunction()
 {
     // Production state
     if (EnemyMainFSM.Instance().LearningDictionary [EMState.Production] > 1f || EnemyMainFSM.Instance().LearningDictionary [EMState.Production] < -1f)
     {
         EnemyMainFSM.Instance().LearningDictionary[EMState.Production] *= 0.95f;
     }
     else
     {
         EnemyMainFSM.Instance().LearningDictionary[EMState.Production] = 0f;
     }
     // Maintain state
     if (EnemyMainFSM.Instance().LearningDictionary [EMState.Maintain] > 1f || EnemyMainFSM.Instance().LearningDictionary [EMState.Maintain] < -1f)
     {
         EnemyMainFSM.Instance().LearningDictionary[EMState.Maintain] *= 0.95f;
     }
     else
     {
         EnemyMainFSM.Instance().LearningDictionary[EMState.Maintain] = 0f;
     }
     // Defend state
     if (EnemyMainFSM.Instance().LearningDictionary [EMState.Defend] > 1f || EnemyMainFSM.Instance().LearningDictionary [EMState.Defend] < -1f)
     {
         EnemyMainFSM.Instance().LearningDictionary[EMState.Defend] *= 0.95f;
     }
     else
     {
         EnemyMainFSM.Instance().LearningDictionary[EMState.Defend] = 0f;
     }
     // AggressiveAttack state
     if (EnemyMainFSM.Instance().LearningDictionary [EMState.AggressiveAttack] > 1f || EnemyMainFSM.Instance().LearningDictionary [EMState.AggressiveAttack] < -1f)
     {
         EnemyMainFSM.Instance().LearningDictionary[EMState.AggressiveAttack] *= 0.95f;
     }
     else
     {
         EnemyMainFSM.Instance().LearningDictionary[EMState.AggressiveAttack] = 0f;
     }
     // CautiousAttack state
     if (EnemyMainFSM.Instance().LearningDictionary [EMState.CautiousAttack] > 1f || EnemyMainFSM.Instance().LearningDictionary [EMState.CautiousAttack] < -1f)
     {
         EnemyMainFSM.Instance().LearningDictionary[EMState.CautiousAttack] *= 0.95f;
     }
     else
     {
         EnemyMainFSM.Instance().LearningDictionary[EMState.CautiousAttack] = 0f;
     }
     // Landmine state
     if (EnemyMainFSM.Instance().LearningDictionary [EMState.Landmine] > 1f || EnemyMainFSM.Instance().LearningDictionary [EMState.Landmine] < -1f)
     {
         EnemyMainFSM.Instance().LearningDictionary[EMState.Landmine] *= 0.95f;
     }
     else
     {
         EnemyMainFSM.Instance().LearningDictionary[EMState.Landmine] = 0f;
     }
 }
コード例 #19
0
    private Vector2 TargetPull()
    {
        Vector2 sumVector = -m_pcFSM.rigidbody2D.position;

        sumVector.x += EnemyMainFSM.Instance().transform.position.x;
        sumVector.y += EnemyMainFSM.Instance().transform.position.y;

        return(sumVector);
    }
コード例 #20
0
    void Start()
    {
        m_EMFSM = GetComponent <EnemyMainFSM> ();

        bCanStartCheck = true;
        fCheckFreq     = 1f;

        bCanRegain  = true;
        fRegainFreq = 1f;
    }
コード例 #21
0
 private bool AreThereTargets()
 {
     if (EnemyMainFSM.Instance().ECList.Count > 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #22
0
 private bool IsTargetAlive()
 {
     if (EnemyMainFSM.Instance().Health > 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #23
0
 float ScoreCompressor(EMState state, float score)
 {
     if (EnemyMainFSM.Instance().LearningDictionary [state] > 0f)
     {
         return(score / Mathf.Sqrt(Mathf.Sqrt(Mathf.Abs(EnemyMainFSM.Instance().LearningDictionary [state]))));
     }
     else
     {
         return(score);
     }
 }
コード例 #24
0
    // GetNearestTargetPosition(): Assign a target to aggressive squad child cells.
    public static bool GetNearestTargetPosition()
    {
        // if: There are no attacking squad children
        if (SquadChildFSM.StateCount(SCState.Attack) == 0)
        {
            return(false);
        }

        s_list_enemyChild = EnemyMainFSM.Instance().ECList;

        // if: There is no enemy child cells to attack
        if (s_list_enemyChild.Count == 0)
        {
            for (int i = 0; i < s_array_SquadChildFSM.Length; i++)
            {
                if (s_array_SquadChildFSM[i].EnumState == SCState.Attack)
                {
                    s_array_SquadChildFSM[i].Advance(SCState.Idle);
                }
            }
            return(false);
        }

        // for: Resets all the attackTarget of all squad children
        for (int i = 0; i < s_array_SquadChildFSM.Length; i++)
        {
            s_array_SquadChildFSM[i].attackTarget = null;
        }

        // for: Every enemy child in the list...
        for (int i = 0; i < s_list_enemyChild.Count; i++)
        {
            // for: Finds a squad children in the list...
            for (int j = 0; j < s_array_SquadChildFSM.Length; j++)
            {
                // if: The current squad children is attacking and it has no target
                if (s_array_SquadChildFSM[j].EnumState == SCState.Attack && s_array_SquadChildFSM[j].attackTarget == null)
                {
                    s_array_SquadChildFSM[j].attackTarget = s_list_enemyChild[i];
                }
            }
        }

        // for: This for loops returns all attacking squad children to idle when they have no target
        for (int i = 0; i < s_array_SquadChildFSM.Length; i++)
        {
            if (s_array_SquadChildFSM[i].EnumState == SCState.Attack && s_array_SquadChildFSM[i].attackTarget == null)
            {
                s_array_SquadChildFSM[i].Advance(SCState.Idle);
            }
        }
        return(true);
    }
コード例 #25
0
    IEnumerator EnemyMainAggressiveAttackWaiting()
    {
        yield return(new WaitForSeconds(2f));

        Tutorial.Instance().tutorialState = TutorialState.EnemyMainAggressiveAttackWaiting;
        StartCoroutine(EMTransition.Instance().TransitionAvailability(6f));
        EnemyMainFSM.Instance().ChangeState(EMState.AggressiveAttack);
        Time.timeScale = 0.75f;
        yield return(new WaitForSeconds(4f));

        Tutorial.Instance().tutorialState = TutorialState.EnemyMainAggressiveAttackCompleted;
    }
コード例 #26
0
    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }

        m_EMFSM    = GetComponent <EnemyMainFSM> ();
        controller = GetComponent <EMController> ();

        bCanTransit = true;
    }
コード例 #27
0
    IEnumerator EnemyMainLandmineWaiting()
    {
        yield return(new WaitForSeconds(2f));

        Tutorial.Instance().tutorialState = TutorialState.EnemyMainLandmineWaiting;
        StartCoroutine(EMTransition.Instance().TransitionAvailability(6f));
        EnemyMainFSM.Instance().ChangeState(EMState.Landmine);
        Time.timeScale = 0.75f;
        yield return(new WaitForSeconds(4f));

        Tutorial.Instance().tutorialState = TutorialState.EnemyMainLandmineCompleted;
        StartCoroutine(Ending());
    }
コード例 #28
0
    IEnumerator EnemyMainProductionWaiting()
    {
        yield return(new WaitForSeconds(3f));

        Tutorial.Instance().tutorialState = TutorialState.EnemyMainProductionWaiting;
        // Prohibit other transitions in the next 6 seconds
        StartCoroutine(EMTransition.Instance().TransitionAvailability(6f));
        // Transition to Production state for demonstration
        EnemyMainFSM.Instance().ChangeState(EMState.Production);
        Time.timeScale = 0.75f;
        yield return(new WaitForSeconds(4f));

        Tutorial.Instance().tutorialState = TutorialState.EnemyMainProductionCompleted;
    }
コード例 #29
0
 // Update the size of enemy main cell according to current health
 private void SizeUpdate()
 {
     if (EnemyMainFSM.Instance() != null)
     {
         if (currentScale != initialScale * Mathf.Sqrt(Mathf.Sqrt(Mathf.Sqrt(Mathf.Pow((float)EnemyMainFSM.Instance().Health, 1.5f)))) &&
             !bIsExpanding &&
             !bIsShrinking &&
             EnemyMainFSM.Instance().CurrentStateIndex != EMState.Die)
         {
             currentScale         = initialScale * Mathf.Sqrt(Mathf.Sqrt(Mathf.Sqrt(Mathf.Pow((float)EnemyMainFSM.Instance().Health, 1.5f))));
             transform.localScale = (Vector3)currentScale;
         }
     }
 }
コード例 #30
0
 void Update()
 {
     // Remove destroyed items in enemy child list
     if (EnemyMainFSM.Instance() != null)
     {
         EnemyMainFSM.Instance().ECList.RemoveAll(item => item.CurrentStateEnum == ECState.Dead);
     }
     //Recalculate available enemy child cells
     m_EMFSM.AvailableChildNum = m_EMFSM.ECList.Count;
     // Check whether the player loses
     LoseCheck();
     // Check if the enemy main cell is visible
     VisibilityCheck();
 }
コード例 #31
0
 // Update the size of enemy main cell according to current health
 private void SizeUpdate()
 {
     if (EnemyMainFSM.Instance() != null)
     {
         if (currentScale != initialScale * fSizeFactor &&
             !bIsExpanding &&
             !bIsShrinking &&
             nCurrentStateNo != 7)
         {
             currentScale         = initialScale * fSizeFactor;
             transform.localScale = (Vector3)currentScale;
         }
     }
 }
コード例 #32
0
    public override void Enter()
    {
        transition = m_EMFSM.emTransition;
        helper     = m_EMFSM.emHelper;

        transition = m_EMFSM.emTransition;
        // Reset transition availability
        transition.CanTransit = true;
        // Pause the transition for randomized time based on num of available child cells
        float fPauseTime = Random.Range(Mathf.Sqrt(Mathf.Sqrt(EnemyMainFSM.Instance().AvailableChildNum) * 10f) / EMDifficulty.Instance().CurrentDiff,
                                        Mathf.Sqrt(Mathf.Sqrt(EnemyMainFSM.Instance().AvailableChildNum) * 50f) / EMDifficulty.Instance().CurrentDiff);

        helper.StartPauseTransition(fPauseTime);
    }
コード例 #33
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        nAvailableChildNum = 0;
        // Initialise num of health and aggressiveness
        nMaxHealth                = nHealth = Settings.s_nEnemyMainInitialHealth;
        nInitialAggressiveness    = Settings.s_nEnemyMainInitialAggressiveness;
        nCurrentAggressiveness    = nInitialAggressiveness;
        nAggressivenessSquadCap   = 0;
        nAggressivenessSquadChild = 0;
    }
コード例 #34
0
    void Awake()
    {
        if (instance == null)
            instance = this;

        nAvailableChildNum = 0;
        // Initialise num of health and aggressiveness
        nMaxHealth = nHealth = Settings.s_nEnemyMainInitialHealth;
        nInitialAggressiveness = Settings.s_nEnemyMainInitialAggressiveness;
        nCurrentAggressiveness = nInitialAggressiveness;
        nAggressivenessSquadCap = 0;
        nAggressivenessSquadChild = 0;
    }
コード例 #35
0
    void Awake()
    {
        if (instance == null)
            instance = this;

        // GetComponent
        m_EMFSM = GetComponent<EnemyMainFSM> ();
        thisRB = GetComponent<Rigidbody2D> ();
        PMain = GameObject.Find("Player_Cell").GetComponent<PlayerMain>();

        // Size
        nInitialNutrientNum = Settings.s_nEnemyMainInitialNutrientNum;
        nCurrentNutrientNum = nInitialNutrientNum;
        // Speed
        fSpeed = Settings.s_fEnemyMainInitialVertSpeed;
        fSpeedFactor = 1f;
        fSpeedTemp = fSpeed;
        bIsDefend = false;
        fDefendFactor = 0.9f;
        // Initialization of horizontal movement
        // Randomize direction
        int nDirection = Random.Range (0, 2);
        if (nDirection == 0)
            bMovingLeft = true;
        else
            bMovingLeft = false;
        // Horizontal speed
        fMinHoriSpeed = Settings.s_fEnemyMainMinHiriSpeed;
        fHoriSpeed = Random.Range (fMinHoriSpeed, fMinHoriSpeed * 2f);
        bCanChangeHori = true;
        // Velocity
        velocity = new Vector2 (fHoriSpeed, fSpeed * fSpeedFactor);
        thisRB.velocity = velocity;
        pushBackVel = new Vector2 (0.0f, -5.0f);
        pushForwardVel = new Vector2 (0.0f, 1.0f);
        stunVel = new Vector2 (0.0f, -0.5f);
        // Damage
        nDamageNum = 0;
        // State
        bPushed = false;
        bStunned = false;
        bCanPush = true;
        bCanStun = true;
        bJustAttacked = false;
        fAttackElapsedTime = 0.1f;
        fDefaultStunTime = Settings.s_fDefaultStunTime;
        fCurrentStunTime = fDefaultStunTime;
        fStunCoolDown = fDefaultStunTime * 2.0f;
        fDefaultStunTolerance = Settings.s_fDefaultStunTolerance;
        fCurrentStunTolerance = fDefaultStunTolerance;

        bIsMainBeingAttacked = false;
        bIsAllChildWithinMain = false;
        fNumOfDefaultCells = Settings.s_nEnemyMainInitialChildCellNum;
    }
コード例 #36
0
    void Start()
    {
        if (instance == null)
            instance = this;

        m_EMFSM = GetComponent<EnemyMainFSM> ();
        controller = GetComponent<EMController> ();

        bCanTransit = true;
    }
コード例 #37
0
 public EMMaintainState(EnemyMainFSM EMFSM)
 {
     m_EMFSM = EMFSM;
 }
コード例 #38
0
    //
    void Start()
    {
        //Initialize the variables and data structure
        m_fRotationTarget = Random.Range(0f,360f);
        m_RandomRotateSpeed = new Vector3(0f,0f,0.85f);
        m_bRotateCW = false;
        m_bRotateACW = false;
        m_PMain = GameObject.Find("Player_Cell");
        m_EMain = GameObject.Find("Enemy_Cell");
        m_EMFSM = m_EMain.GetComponent<EnemyMainFSM>();
        m_EMControl = m_EMain.GetComponent<EMController>();
        m_Rigidbody2D = GetComponent<Rigidbody2D>();
        m_ChildTransform = transform;

        m_ChargeTarget = null;
        m_StatesDictionary = new Dictionary<ECState,IECState>();

        m_AudioSource = GetComponent<AudioSource>();

        //Initialize the various states for the enemy child cell and added them into the dictionary
        m_StatesDictionary.Add(ECState.Idle, new ECIdleState(this.gameObject,this));
        m_StatesDictionary.Add(ECState.Defend, new ECDefendState(this.gameObject,this));
        m_StatesDictionary.Add(ECState.Avoid, new ECAvoidState(this.gameObject,this));
        m_StatesDictionary.Add(ECState.Attack, new ECAttackState(this.gameObject,this));
        m_StatesDictionary.Add(ECState.ChargeMain, new ECChargeMState(this.gameObject,this));
        m_StatesDictionary.Add(ECState.ChargeChild, new ECChargeCState(this.gameObject,this));
        m_StatesDictionary.Add(ECState.TrickAttack, new ECTrickAttackState(this.gameObject,this));
        m_StatesDictionary.Add(ECState.Landmine, new ECMineState(this.gameObject,this));
        m_StatesDictionary.Add(ECState.Dead, new ECDeadState(this.gameObject,this));

        //initialize the current state for the enemy child cell
        m_CurrentState = m_StatesDictionary[ECState.Dead];
        m_CurrentEnum = ECState.Dead;
        m_CurrentCommand = MessageType.Empty;
        CurrentState.Enter();
    }
コード例 #39
0
 public EMLandmineState(EnemyMainFSM EMFSM)
 {
     m_EMFSM = EMFSM;
 }
コード例 #40
0
    void Start()
    {
        m_EMFSM = GetComponent<EnemyMainFSM> ();

        bCanStartCheck = true;
        fCheckFreq = 1f;

        bCanRegain = true;
        fRegainFreq = 1f;
    }
コード例 #41
0
 public static void ResetStatics()
 {
     instance = null;
 }
コード例 #42
0
 public EMProductionState(EnemyMainFSM EMFSM)
 {
     m_EMFSM = EMFSM;
 }
コード例 #43
0
	public EMCautiousAttackState (EnemyMainFSM EMFSM)
	{
		m_EMFSM = EMFSM;
	}
コード例 #44
0
 public EMStunnedState(EnemyMainFSM EMFSM)
 {
     m_EMFSM = EMFSM;
 }
コード例 #45
0
 public EMDieState(EnemyMainFSM EMFSM)
 {
     m_EMFSM = EMFSM;
 }