Пример #1
0
    private void TargetShowSubstractGold(NetworkConnection target, Constant.SpawnTypeUnit typeOfUnit)
    {
        int    cost = GameManager.Instance.GetUnitForPlayer(typeOfUnit, m_playerNumber).GetComponent <UnitController>().GetUnitCost();
        string text = "-" + cost.ToString();

        m_substractGoldUI.SpawnText(text, .5f);
    }
Пример #2
0
    private void CreateUnit(Constant.SpawnTypeUnit spawnType)
    {
        GameObject go = Instantiate(GameManager.Instance.GetUnitForPlayer(spawnType, m_playerNumber), m_door.position, m_door.rotation);

        NetworkServer.Spawn(go);
        GameManager.Instance.GetPlayer(m_playerNumber).IncrementNbUnitInGame();
        RpcPlaySpawnFX();
        UnitController goUnitController = go.GetComponent <UnitController>();

        goUnitController.SetObjective(m_target.transform.position);
        goUnitController.SetPlayerNumber(m_playerNumber);
        goUnitController.SetParentPath(m_path);
        goUnitController.SetNexusEnemy(m_target.transform.position);
        if (m_playerNumber != PlayerEntity.Player.Bot)
        {
            TargetSoundEmitter(GameManager.Instance.GetPlayer(m_playerNumber).connectionToClient);
        }
    }
Пример #3
0
    public void CmdAddToUnitsQueue(Constant.SpawnTypeUnit typeOfUnit)
    {
        PlayerEntity player     = GameManager.Instance.GetPlayer(m_playerNumber);
        GameObject   prefabTemp = GameManager.Instance.GetUnitForPlayer(typeOfUnit, m_playerNumber);

        if (player.GetUnitGold() < prefabTemp.GetComponent <UnitController>().GetUnitCost())
        {
            TargetShowUIWarningUnit(player.connectionToClient);
            return;
        }
        player.SubstractUnitGold(prefabTemp.GetComponent <UnitController>().GetUnitCost());
        TargetShowSubstractGold(player.connectionToClient, typeOfUnit);
        TargetSound(player.connectionToClient, SoundManager.AudioClipList.AC_unitBuy);
        m_unitsQueue.Add(typeOfUnit);
        if (m_unitsQueue.Count > 1)
        {
            return;
        }
        InvokeRepeating("SpawnUnitsFromQueue", m_secondsBeforeSpawn, m_secondsBeforeSpawn);
    }
Пример #4
0
    public void MakeAction(Animator animator)
    {
        float ratio = Random.Range(0f, 1f);

        if (ratio < m_unitSpawnRatio) // SpawnUnits
        {
            int idSpawnUnit = Random.Range(0, m_botSpawnUnits.Count);
            Constant.SpawnTypeUnit unitType   = m_listSpawnTypeUnit[Random.Range(0, m_listSpawnTypeUnit.Count)];
            GameObject             prefabTemp = GameManager.Instance.GetUnitForPlayer(unitType);
            if (GameManager.Instance.GetPlayer(PlayerEntity.Player.Bot).GetUnitGold() >= prefabTemp.GetComponent <UnitController>().GetUnitCost())
            {
                m_unitsQueue.Clear();
                m_unitsQueue.Add(unitType);
                m_botSpawnUnits[idSpawnUnit].SetUnitsQueue(m_unitsQueue);
            }

            m_aiSpawnUnit.SetIndexSpawUnits(idSpawnUnit);
            m_aiSpawnUnit.SetListeSpawnUnits(m_botSpawnUnits);
            animator.SetTrigger(Constant.BotTransition.s_spawnUnit);
        }

        else if (m_unitSpawnRatio <= ratio && ratio < m_unitSpawnRatio + m_obstaclesRatio) // Obstacles Build/Destroy
        {
            int index = Random.Range(0, m_listObstacles.Count);

            if (m_listObstacles[index].GetCurrentState() == ObstacleConstructor.EState.Buildable)
            {
                m_aiBuildObstacle.SetIndex(index);
                m_aiBuildObstacle.SetObstacleConstructorList(m_listObstacles);
                int typeBuildIndex = Random.Range(0, m_listSpawnTypeObstacle.Count);
                m_aiBuildObstacle.SetTypeBuild(m_listSpawnTypeObstacle[typeBuildIndex]);
                animator.SetTrigger(Constant.BotTransition.s_buildObstacle);
            }

            //if (m_listObstacles[index].GetCurrentState() == ObstacleConstructor.EState.Built)
            //{
            //    m_aiDestroyObstacle.SetIndex(index);
            //    m_aiDestroyObstacle.SetObstacleConstructorList(m_listObstacles);
            //    animator.SetTrigger(Constant.BotTransition.s_destroyObstacle);
            //}
        }

        else
        {
            m_indexCheckpoint = Random.Range(0, m_listCheckpoints.Count);
            if (m_unitSpawnRatio + m_obstaclesRatio <= ratio &&
                ratio < m_unitSpawnRatio + m_obstaclesRatio + m_checkpointsReleaseAllRatio) // Checkpoints ReleaseAll
            {
                m_nbUnitsReleased = m_listCheckpoints[m_indexCheckpoint].GetNbUnitsStocked();
            }

            else if (m_unitSpawnRatio + m_obstaclesRatio + m_checkpointsReleaseAllRatio <= ratio &&
                     ratio < m_unitSpawnRatio + m_obstaclesRatio + m_checkpointsReleaseAllRatio + m_checkpointsReleaseRatio) // Checkpoints Release
            {
                m_nbUnitsReleased = 1;
            }

            if (m_listCheckpoints[m_indexCheckpoint].GetNbUnitsStocked() >= m_nbUnitsReleased && m_nbUnitsReleased != 0)
            {
                m_aiReleaseUnits.SetListCheckpoints(m_listCheckpoints);
                m_aiReleaseUnits.SetIndexCheckpoint(m_indexCheckpoint);
                m_aiReleaseUnits.SetNbUnitsReleased(m_nbUnitsReleased);
                animator.SetTrigger(Constant.BotTransition.s_releaseUnits);
            }
        }
    }
Пример #5
0
 /// <summary>
 /// Returns the gameobject linked to a SpawnType of a player
 /// </summary>
 /// <returns>The unit for player.</returns>
 /// <param name="type">Unit spawn type</param>
 /// <param name="playerNumber">Player1 for syca, other Player for arca. Do not set any value to use LocalPlayer</param>
 public GameObject GetUnitForPlayer(Constant.SpawnTypeUnit type, PlayerEntity.Player playerNumber = PlayerEntity.Player.Neutre)
 {
     playerNumber = playerNumber == PlayerEntity.Player.Neutre ? GetLocalPlayer() : playerNumber;
     return(m_prefabUnits[playerNumber][type]);
 }