Ejemplo n.º 1
0
    private void ResetLevel()
    {
        if (m_pathRenderer != null)
        {
            m_pathRenderer.clear_paths();
        }

        m_matchOpeningAnimIds.Clear();

        if (m_playerTeam != null)
        {
            TeamBase team = m_playerTeam.GetComponent <TeamBase>();
            foreach (BotBase member in team.TeamMembers)
            {
                if (member != null)
                {
                    GameObject.Destroy(member.gameObject);
                }
            }
            GameObject.Destroy(m_playerTeam.gameObject);
        }

        if (m_enemyTeam != null)
        {
            TeamBase team = m_enemyTeam.GetComponent <TeamBase>();
            foreach (BotBase member in team.TeamMembers)
            {
                if (member != null)
                {
                    GameObject.Destroy(member.gameObject);
                }
            }
            GameObject.Destroy(m_enemyTeam.gameObject);
        }

        if (m_looseBalls != null)
        {
            for (int i = 0; i < m_looseBalls.Count; i++)
            {
                GameObject.Destroy(m_looseBalls[i].gameObject);
            }
            m_looseBalls.Clear();
        }

        m_playerTeamFootballers.Clear();
        m_enemyTeamFootballers.Clear();

        m_playerTeamFootballersWithBall.Clear();
        m_enemyTeamFootballersWithBall.Clear();
        if (m_particles != null)
        {
            m_particles.clear();
        }
        // Memory cleanup.
        {
            System.GC.Collect();
            Resources.UnloadUnusedAssets();
        }
        Main.GameCamera.reset();
    }
Ejemplo n.º 2
0
 void OnTeamEliminated(TeamBase team)
 {
     if (team == teamToEliminate)
     {
         OnObjectiveCompleted(teamToEliminate.name);
     }
 }
Ejemplo n.º 3
0
 private void Initialisation()
 {
     playerBase = GameObject.Find ("playerBase").GetComponent<TeamBase> ();
     if (playerBase == null) {
         Debug.Log ("something went wrong while fetching ennemy base");
     }
 }
Ejemplo n.º 4
0
    private TeamBase CreateTeam(Team team)
    {
        GameObject neu_obj = Util.proto_clone(proto_team);
        TeamBase   rtv     = neu_obj.GetComponent <TeamBase>();

        rtv.Team = team;
        return(rtv);
    }
 void OnTeamTurnStarted(TeamBase team)
 {
     if (team.GetType() == typeof(CAITeam))
     {
         banner.SetActive(true);
     }
     else
     {
         banner.SetActive(false);
     }
 }
Ejemplo n.º 6
0
    void UpdateStatics()
    {
        _TUnit = tUnit;
        _BUnit = bUnit;
        leftTeam.baseScript  = leftTeam.baseObject.GetComponent <StatueScript>();
        rightTeam.baseScript = rightTeam.baseObject.GetComponent <StatueScript>();
        _LTeam = leftTeam;
        _RTeam = rightTeam;

        _Top               = top;
        _Bottom            = bottom;
        _Left              = left;
        _Right             = right;
        _ArenaDiv          = arenaDiv;
        _BaseMoveOnMeasure = basesOnMeasures;
    }
    void OnLevelWon(TeamBase team)
    {
        bool didThisPlayerWin = false;

        if (!isMultiplayerLevel)
        {
            didThisPlayerWin = !team.IsTeamAI();
        }
        else
        {
            didThisPlayerWin = team.GetLocalPlayerNumber() == team.GetTeamNumber();
        }

        panelText.text = didThisPlayerWin ? levelWinText : levelLoseText;
        levelCompletedPanel.SetActive(true);
    }
Ejemplo n.º 8
0
    void Update()
    {
        respawnTime -= Time.deltaTime;

        if (respawnTime <= 0)
        {
            // Need to disable the respawn component,
            enabled = false;

            // and re-enable the components which we disabled before.
            GetComponent <Collider>().enabled = true;
            GetComponent <PlayerTankForceMovement>().enabled = true;


            // and "Respawn"
            // it's easier to just retain the object as it was.
            float      bestDist        = Mathf.Infinity;
            TeamBase   baseToRespawnAt = null;
            TeamBase[] bases           = FindObjectsOfType(typeof(TeamBase)) as TeamBase[];

            foreach (TeamBase teamBase in bases)
            {
                float distanceTo = Vector3.Distance(transform.position, teamBase.transform.position);

                // The closest base of the same team.
                if (teamBase.team == gameObject.GetComponent <TeamPlayer>().team&&
                    distanceTo < bestDist)
                {
                    baseToRespawnAt = teamBase;
                    bestDist        = distanceTo;
                }
            }

            if (baseToRespawnAt == null)
            {
                // Game over...
            }

            GetComponent <TeamPlayer>().health = 100; // MAGIC: 2018-07-07: Assumes player has 100 initial health
            // FIXME: 2018-07-07:
            transform.position = baseToRespawnAt.mechSpawnPoint.position;
            transform.rotation = baseToRespawnAt.mechSpawnPoint.rotation;

            // Get the player UI, so we can re-show the objective.
            GetComponent <PlayerUI>().objectiveOpacity = 0.5f + 1.0f; // MAGIC.
        }
    }
Ejemplo n.º 9
0
    private BotBase CreateFootballer(TeamBase team, Vector3 pos, FootballerAnimResource anims)
    {
        GameObject        neu_obj = Util.proto_clone(proto_genericFootballer);
        GenericFootballer rtv     = neu_obj.GetComponent <GenericFootballer>();

        rtv.transform.position = pos;
        rtv.sim_initialize(anims);
        if (team.Team == Team.PlayerTeam)
        {
            m_playerTeamFootballers.Add(rtv);
        }
        else
        {
            m_enemyTeamFootballers.Add(rtv);
        }
        return(neu_obj.GetComponent <BotBase>());
    }
Ejemplo n.º 10
0
    private void SpawnTeam(int centerRegion, TeamBase team,
                           int[] regions, FootballerResourceKey[] resources, FieldPosition[] fieldPositions)
    {
        const float    startOffset = 100.0f;
        Vector3        centerPos   = Main.FieldController.GetRegionPosition(centerRegion);
        float          deltaAngle  = Mathf.Deg2Rad * (360.0f / regions.Length);
        List <BotBase> bots        = new List <BotBase>(regions.Length);

        for (int i = 0; i < regions.Length; i++)
        {
            BotBase bot = this.CreateFootballer(team,
                                                centerPos + Uzu.Math.RadiansToDirectionVector(deltaAngle * i) * startOffset,
                                                SpriteResourceDB.get_footballer_anim_resource(resources[i]));
            bot.HomePosition  = Main.FieldController.GetRegionPosition(regions[i]);
            bot.FieldPosition = fieldPositions[i];
            bots.Add(bot);
        }
        team.SetPlayers(bots);
    }
Ejemplo n.º 11
0
    void OnTeamTurnEnded(TeamBase team)
    {
        if (team != teams[currentTeamIndex])
        {
            Debug.LogError("The team whose turn ended wasn't the currently selected team in the LevelManager! This should never happen!");
            return;
        }

        if (!isLevelCompleted)
        {
            if (isMultiplayerLevel)
            {
                PhotonView photonView = PhotonView.Get(this);
                photonView.RPC("BeginNextTeamTurn", RpcTarget.All);
            }
            else
            {
                BeginNextTeamTurn();
            }
        }
    }
Ejemplo n.º 12
0
    public BotBase GetClosestTeammate()
    {
        var   members = TeamBase.GetTeamExcept(this);
        float minDist = float.MaxValue;
        int   minIdx  = -1;

        for (int i = 0; i < members.Count; i++)
        {
            float dist = Vector3.Distance(this.transform.position, members[i].transform.position);
            if (dist < minDist)
            {
                minDist = dist;
                minIdx  = i;
            }
        }
        if (minIdx == -1)
        {
            Debug.Log("No one to pass to!");
            return(null);
        }
        return(members[minIdx]);
    }
    public void CaptureBase (PlayerTankForceMovement buyer) {
        TeamBase teamBase =
            transform.parent.GetComponent<TeamBase>(); // Assume that BuyCaptureBase is a child of the base.

        if (teamBase == null) { // TIDYME: 2018-07-07: Use Assert
            Debug.Log("BuyCaptureBase could not find the base we're capturing!?");
        }

        // Set the team of the base
        if (buyer == null) { Debug.Log("CapBase.. buyer is null"); }
        if (buyer.GetComponent<TeamPlayer>() == null) { Debug.Log("CapBase.. buyer TP is null"); }
        teamBase.team = buyer.GetComponent<TeamPlayer>().team;

        // Now enable all the colliders and renderers in the children...
        // ... for some reason, the polymorphism here was wonky. *sigh*.

        Component[] colliders = teamBase.GetComponentsInChildren<Collider>(true);
        foreach (Component collider in colliders) {
            collider.GetComponent<Collider>().enabled = true;
        }

        MeshRenderer[] renderers = base.transform.GetComponentsInChildren<MeshRenderer>(true);
        foreach (MeshRenderer renderer in renderers) {
            renderer.enabled = true;
        }

        TowerLive[] towers = teamBase.transform.GetComponentsInChildren<TowerLive>(true);
        foreach (TowerLive tower in towers) {
            tower.enabled = true;
            (tower.GetComponent<TeamPlayer>() as TeamPlayer).team = teamBase.team;
            tower.UpdateTextureToTeamColor();
        }

        // And hide the buy base..
        GetComponentInChildren<Renderer>().enabled = false;
        GetComponent<Collider>().enabled = false;
    }
Ejemplo n.º 14
0
 protected virtual void LeftTeamWins()
 {
     winnerTeam = leftTeam;
     EndBattle();
 }
Ejemplo n.º 15
0
    public void StartLevel(StartMode startMode = StartMode.Sequence)
    {
        Main.AudioController.PlayEffect("crowd");
        ResetLevel();
        _last_mouse_position             = new Vector3(0, -300, 0);
        _last_mouse_point_in_ball_bounds = new Vector3(0, 0, 0);       //i dont even
        _last_mouse_point_in_ball_bounds = Vector3.zero;
        //Debug.Log("Start level: " + CurrentDifficulty);

        m_commentaryManager = new InGameCommentaryManager();

        m_pathRenderer = this.GetComponent <PathRenderer>();

        m_playerTeam = this.CreateTeam(Team.PlayerTeam);
        m_enemyTeam  = this.CreateTeam(Team.EnemyTeam);

        this.set_time_remaining_seconds(300);

        if (CurrentDifficulty == Difficulty.Easy)
        {
            this.set_time_remaining_seconds(300);
            _player_team_score = 0;
            _enemy_team_score  = 0;
            _quarter_display   = "1ST";
            {
                int[] regions = { 7, 6, 8 };
                FootballerResourceKey[] keys = { FootballerResourceKey.Player1, FootballerResourceKey.Player1, FootballerResourceKey.Player1 };
                FieldPosition[]         fps  = { FieldPosition.Keeper, FieldPosition.Defender, FieldPosition.Defender };
                SpawnTeam(7, m_playerTeam, regions, keys, fps);
            }
            {
                int[] regions = { 16, 12, 14 };
                FootballerResourceKey[] keys = { FootballerResourceKey.EnemyGoalie, FootballerResourceKey.Enemy3, FootballerResourceKey.Enemy3 };
                FieldPosition[]         fps  = { FieldPosition.Keeper, FieldPosition.Defender, FieldPosition.Defender };
                SpawnTeam(10, m_enemyTeam, regions, keys, fps);
            }
            m_commentaryManager.notify_do_tutorial();
        }
        else if (CurrentDifficulty == Difficulty.Normal)
        {
            this.set_time_remaining_seconds(200);
            _player_team_score = 2;
            _enemy_team_score  = 2;
            _quarter_display   = "2ND";
            {
                int[] regions = { 7, 3, 4, 5 };
                FootballerResourceKey[] keys = { FootballerResourceKey.Player1, FootballerResourceKey.Player1, FootballerResourceKey.Player1, FootballerResourceKey.Player1 };
                FieldPosition[]         fps  = { FieldPosition.Keeper, FieldPosition.Defender, FieldPosition.Defender, FieldPosition.Attacker };
                SpawnTeam(7, m_playerTeam, regions, keys, fps);
            }
            {
                int[] regions = { 16, 12, 14, 13 };
                FootballerResourceKey[] keys = { FootballerResourceKey.EnemyGoalie, FootballerResourceKey.Enemy3, FootballerResourceKey.Enemy3, FootballerResourceKey.Enemy2 };
                FieldPosition[]         fps  = { FieldPosition.Keeper, FieldPosition.Defender, FieldPosition.Defender, FieldPosition.Attacker };
                SpawnTeam(10, m_enemyTeam, regions, keys, fps);
            }
        }
        else
        {
            this.set_time_remaining_seconds(120);
            _player_team_score = 4;
            _enemy_team_score  = 4;
            _quarter_display   = "4TH";
            {
                int[] regions = { 7, 3, 5, 6, 8 };
                FootballerResourceKey[] keys = { FootballerResourceKey.Player1, FootballerResourceKey.Player1, FootballerResourceKey.Player1, FootballerResourceKey.Player1, FootballerResourceKey.Player1 };
                FieldPosition[]         fps  = { FieldPosition.Keeper, FieldPosition.Defender, FieldPosition.Defender, FieldPosition.Attacker, FieldPosition.Attacker };
                SpawnTeam(7, m_playerTeam, regions, keys, fps);
            }
            {
                int[] regions = { 16, 12, 14, 9, 11 };
                FootballerResourceKey[] keys = { FootballerResourceKey.EnemyGoalie, FootballerResourceKey.Enemy3, FootballerResourceKey.Enemy3, FootballerResourceKey.Enemy2, FootballerResourceKey.Enemy2 };
                FieldPosition[]         fps  = { FieldPosition.Keeper, FieldPosition.Defender, FieldPosition.Defender, FieldPosition.Attacker, FieldPosition.Attacker };
                SpawnTeam(10, m_enemyTeam, regions, keys, fps);
            }
        }

        // Debugging.
        if (Main.FSMDebugger != null)
        {
            Main.FSMDebugger.Team = m_enemyTeam;
        }

        if (m_mouseTargetIcon == null)
        {
            m_mouseTargetIcon = Util.proto_clone(proto_mouseTarget);
        }
        if (m_particles == null)
        {
            m_particles = SPParticleSystem.cons_anchor(Main.Instance._particleRoot.transform);
        }

        if (m_topReferee == null)
        {
            m_topReferee    = Util.proto_clone(proto_referee).GetComponent <Referee>();
            m_bottomReferee = Util.proto_clone(proto_referee).GetComponent <Referee>();
        }
        m_topReferee.sim_initialize(Referee.RefereeMode.Top);
        m_bottomReferee.sim_initialize(Referee.RefereeMode.Bottom);

        Main.GameCamera.SetTargetPos(new Vector3(0, -300, 0));
        Main.GameCamera.SetTargetZoom(800);
        switch (startMode)
        {
        case StartMode.Sequence:
            DoMatchOpeningSequence();
            break;

        case StartMode.Immediate:
            DoMatchOpeningImmediate();
            break;
        }
    }
    void OnTriggerStay(Collider other)
    {
        if (t > 0)
        {
            // Place a limit on how frequently actions will happen,
            // if the button is pressed down.
            return;
        }

        TeamPlayer mechTeamPlayer = transform.parent.GetComponent <TeamPlayer>();

        status = null;

        // For "Capturing" towers
        if (other.GetComponent <TowerInactive>() != null)
        {
            status = "< Press Action to Capture Tower >";

            if (Input.GetAxis(actionAxis) > 0)
            {
                TowerInactive inactiveTower = other.GetComponent <TowerInactive>();

                inactiveTower.ReplaceWithLiveTower(mechTeamPlayer.team);

                t = 1.0f / actionFrequency;
            }
        }

        // For buying bot tanks, jets
        if (other.GetComponent <BuyBotPOS>() != null)
        {
            if (PlayerScores.GetTeamScore(mechTeamPlayer.team) >= PlayerScores.botTankCost)
            {
                status = "< Press Action to Buy Bot >";
            }
            else
            {
                status = "< You Do not have enough points to Buy a Bot >";
            }

            if (Input.GetAxis(actionAxis) > 0 &&
                PlayerScores.GetTeamScore(mechTeamPlayer.team) >= PlayerScores.botTankCost)
            {
                // Get the base, which is the parent of the BuyBotPOS gameobj
                TeamBase teamBase = other.gameObject.transform.parent.GetComponent <TeamBase>();

                PlayerScores.AddTeamScore(mechTeamPlayer.team, -PlayerScores.botTankCost);

                // Will only spawn tanks for now..... TODO
                teamBase.SpawnBotTank();

                t = 1.0f / actionFrequency;
            }
        }



        // For buying ammo
        if (other.GetComponent <BuyAmmoPOS>() != null)
        {
            if (PlayerScores.GetTeamScore(mechTeamPlayer.team) >= PlayerScores.buyRocketCost)
            {
                status = "< Press Action to Buy Ammo >";
            }
            else
            {
                status = "< You Do not have enough points to Buy Ammo >";
            }

            if (Input.GetAxis(actionAxis) > 0 &&
                PlayerScores.GetTeamScore(mechTeamPlayer.team) >= PlayerScores.buyRocketCost)
            {
                // Get the weapon we add the ammo to.
                Transform rktShooter = transform.parent.Find("playerRktShooter"); // Somewhat MAGIC; 2018-07-07: Use Property, not Find

                if (rktShooter == null)
                {
                    Debug.Log("Couldn't find playerRktShooter of Player.");
                }

                // Add howevermany hitpoints to player's health,
                // and deduct however many points
                rktShooter.GetComponent <BulletShooter>().ammoCount = PlayerScores.buyRocketAmount;
                PlayerScores.AddTeamScore(mechTeamPlayer.team, -PlayerScores.buyRocketCost);

                t = 1.0f / actionFrequency;
            }
        }

        // For Health
        if (other.GetComponent <BuyHealthPOS>() != null)
        {
            if (PlayerScores.GetTeamScore(mechTeamPlayer.team) >= PlayerScores.buyHealthCost)
            {
                status = "< Press Action to Buy Health >";
            }
            else
            {
                status = "< You Do not have enough points to Buy Health >";
            }

            if (Input.GetAxis(actionAxis) > 0 &&
                PlayerScores.GetTeamScore(mechTeamPlayer.team) >= PlayerScores.buyHealthCost)
            {
                // Add howevermany hitpoints to player's health (max 100. MAGIC).
                // and deduct however many points
                mechTeamPlayer.health = Mathf.Min(100, mechTeamPlayer.health + PlayerScores.buyHealthAmount);
                PlayerScores.AddTeamScore(mechTeamPlayer.team, -PlayerScores.buyHealthCost);

                t = 1.0f / actionFrequency;
            }
        }

        // For buying/capturing a base
        if (other.GetComponent <BuyCapturableBase>() != null)
        {
            if (PlayerScores.GetTeamScore(mechTeamPlayer.team) >= PlayerScores.uncapturedBaseCost)
            {
                status = "< Press Action to Buy Forward Base >";
            }
            else
            {
                status = "< You Do not have enough points to Buy the Forward Base >";
            }

            if (Input.GetAxis(actionAxis) > 0 &&
                PlayerScores.GetTeamScore(mechTeamPlayer.team) >= PlayerScores.uncapturedBaseCost)
            {
                // Deduct the appropriate amount.
                PlayerScores.AddTeamScore(mechTeamPlayer.team, -PlayerScores.uncapturedBaseCost);

                other.GetComponent <BuyCapturableBase>().CaptureBase(transform.parent.GetComponent <PlayerTankForceMovement>());

                t = 1.0f / actionFrequency;
            }
        }
    }
Ejemplo n.º 17
0
    protected void initalisation()
    {
        player = GameObject.FindGameObjectWithTag ("Player");
        if (player == null) {
            Debug.Log ("something went wrong while fetching player");
        }

        playerFlag = GameObject.Find ("Drapeau_Gentil").GetComponent<DrapeauBehavior> ();
        if (playerFlag == null) {
            Debug.Log ("something went wrong while fetching player flag");
        }

        ennemyFlag = GameObject.Find ("Drapeau_Ennemi").GetComponent<DrapeauBehavior> ();
        if (ennemyFlag == null) {
            Debug.Log ("something went wrong while fetching ennemy flag");
        }

        ennemyBase = GameObject.Find ("ennemyBase").GetComponent<TeamBase> ();
        if (ennemyBase == null) {
            Debug.Log ("something went wrong while fetching ennemy base");
        }

        rb = GetComponent<Rigidbody> ();
        if (rb == null) {
            Debug.Log ("something went wrong while fetching the rigidbody");
        }

        currentLifePoint = lifePoints;
    }
Ejemplo n.º 18
0
 void OnTeamTurnStarted(TeamBase team) => currentlySelectedTeam = team;
Ejemplo n.º 19
0
 void OnTeamTurnStarted(TeamBase team)
 {
     AddLog("Team " + team.name + " is starting their turn!");
 }
Ejemplo n.º 20
0
 protected virtual void RigthTeamWins()
 {
     winnerTeam = rigthTeam;
     EndBattle();
 }
Ejemplo n.º 21
0
    void OnTeamTurnStarted(TeamBase team)
    {
        PhotonView photonView = GetComponent <PhotonView>();

        photonView.RPC("UpdateUIOnTurnStart", RpcTarget.All, team.GetTeamNumber());
    }