Ejemplo n.º 1
0
        public void Attack()
        {
            if (this.targetEnemy != null)
            {
                //Attack Reach. If a nearby enemy game unit is within attack range, engage and attack.
                AttackArea area = this.GetComponentInChildren <AttackArea>();
                if (area != null)
                {
                    if (area.enemiesInAttackRange.Contains(this.targetEnemy))
                    {
                        if (this.attackCooldownCounter <= 0f)
                        {
                            CmdAttack(this.targetEnemy.gameObject, this.unitAttributes.attackCooldownPrefabList[this.level]);

                            GameMetricLogger.Increment(GameMetricOptions.Attacks);
                            GameMetricLogger.Increment(GameMetricOptions.AttackTime);
                        }
                    }
                    else if (area.enemiesInAttackRange.Count > 0)
                    {
                        this.targetEnemy = area.enemiesInAttackRange[0];
                    }

                    GameMetricLogger.Increment(GameMetricOptions.BattleEngagementTime);
                }
            }
            else if (this.targetAIEnemy != null)
            {
                AttackArea area = this.GetComponentInChildren <AttackArea>();
                if (area != null)
                {
                    if (area.otherEnemies.Contains(this.targetAIEnemy))
                    {
                        if (this.attackCooldownCounter <= 0f)
                        {
                            if (this.unitAttributes.attackCooldownPrefabList.Count > 0)
                            {
                                AttackAI(this.targetAIEnemy.gameObject, this.unitAttributes.attackCooldownPrefabList[this.level]);
                            }
                            else
                            {
                                AttackAI(this.targetAIEnemy.gameObject, 1f);
                            }

                            GameMetricLogger.Increment(GameMetricOptions.Attacks);
                            GameMetricLogger.Increment(GameMetricOptions.AttackTime);
                        }
                    }
                    else if (area.otherEnemies.Count > 0)
                    {
                        this.targetAIEnemy = area.otherEnemies[0];
                    }

                    GameMetricLogger.Increment(GameMetricOptions.BattleEngagementTime);
                }
            }
        }
Ejemplo n.º 2
0
    /*
     *      ██╗      █████╗ ███╗   ██╗     ██████╗██╗     ██╗███████╗███╗   ██╗████████╗
     *      ██║     ██╔══██╗████╗  ██║    ██╔════╝██║     ██║██╔════╝████╗  ██║╚══██╔══╝
     *      ██║     ███████║██╔██╗ ██║    ██║     ██║     ██║█████╗  ██╔██╗ ██║   ██║
     *      ██║     ██╔══██║██║╚██╗██║    ██║     ██║     ██║██╔══╝  ██║╚██╗██║   ██║
     *      ███████╗██║  ██║██║ ╚████║    ╚██████╗███████╗██║███████╗██║ ╚████║   ██║
     *      ╚══════╝╚═╝  ╚═╝╚═╝  ╚═══╝     ╚═════╝╚══════╝╚═╝╚══════╝╚═╝  ╚═══╝   ╚═╝
     */


    //Turning on/off menu
    public void TurnOnLANClientMenu()
    {
        this.initialMenu.SetActive(false);
        this.optionsMenu.SetActive(false);
        this.unitAttributeEditor.SetActive(false);
        this.LANHost.SetActive(false);
        this.LANClientNotConnected.SetActive(true);

        GameMetricLogger.SetGameLogger(GameLoggerOptions.GameIsOver);
    }
Ejemplo n.º 3
0
        public void UpdateSplitGroup()
        {
            if (this.splitGroupList != null && this.splitGroupList.Count > 0)
            {
                for (int i = 0; i < this.splitGroupList.Count; i++)
                {
                    SplitGroup group = this.splitGroupList[i];
                    if (group.elapsedTime >= 1f)
                    {
                        group.Stop();
                        Increment(group.ownerUnit);
                        Decrement(group.ownerUnit);
                        Increment(group.splitUnit);
                        Decrement(group.splitUnit);
                        if (group.splitUnit != null && !this.selectionManager.allObjects.Contains(group.splitUnit.gameObject))
                        {
                            this.selectionManager.allObjects.Add(group.splitUnit.gameObject);
                        }
                        if (!this.selectionManager.allObjects.Contains(group.ownerUnit.gameObject))
                        {
                            this.selectionManager.allObjects.Add(group.ownerUnit.gameObject);
                        }
                        if (group.ownerUnit.transform.parent == null || !group.ownerUnit.transform.parent.Equals(this.unitParent))
                        {
                            group.ownerUnit.transform.SetParent(this.unitParent);
                        }
                        if (group.splitUnit.transform.parent == null || !group.splitUnit.transform.parent.Equals(this.unitParent))
                        {
                            group.splitUnit.transform.SetParent(this.unitParent);
                        }
                        this.removeList.Add(group);

                        GameMetricLogger.Increment(GameMetricOptions.Splits);
                    }
                    else
                    {
                        //Some weird C# language design...
                        group.Update();
                        group.elapsedTime     += Time.deltaTime / group.splitFactor;
                        this.splitGroupList[i] = group;
                    }
                }
            }

            if (this.removeList != null && this.removeList.Count > 0)
            {
                foreach (SplitGroup group in this.removeList)
                {
                    this.splitGroupList.Remove(group);
                }
                this.removeList.Clear();
            }
        }
Ejemplo n.º 4
0
 public void RpcShowReport()
 {
     NewSpawner[] spawners = GameObject.FindObjectsOfType <NewSpawner>();
     if (spawners.Length > 0)
     {
         for (int i = 0; i < spawners.Length; i++)
         {
             spawners[i].isGameStart = false;
             GameMetricLogger.ShowPrintLog();
         }
     }
 }
Ejemplo n.º 5
0
    public void StartLANHost()
    {
        this.PreInitialization();

        this.networkManager.StartHost();
        this.initialMenu.SetActive(false);
        this.optionsMenu.SetActive(false);
        this.LANClientReady.SetActive(false);
        this.LANClientNotReady.SetActive(false);
        this.LANHost.SetActive(true);
        this.LANClientNotConnected.SetActive(false);
        EnableAttributeEditor enableEditorObj = this.optionsMenu.GetComponentInChildren <EnableAttributeEditor>();

        if (enableEditorObj != null)
        {
            enableEditorObj.TurnOffCanvasGroup();
        }

        this.PreUnitAttributesInitialization();

        MinimapStuffs stuffs = GameObject.FindObjectOfType <MinimapStuffs>();

        if (stuffs != null)
        {
            Camera minimapCamera = stuffs.GetComponent <Camera>();
            minimapCamera.enabled      = true;
            stuffs.playerCameraPanning = Camera.main.GetComponent <CameraPanning>();
        }

        string name = this.playerNameField.text;

        if (name.Length > 0)
        {
            GameMetricLogger.instance.playerName = name;
        }
        else
        {
            GameMetricLogger.instance.playerName = "Player";
        }

        if (Taskbar.Instance != null)
        {
            Taskbar.Instance.ShowTaskbar(true);
        }

        GameMetricLogger.instance.difficultyEquations = this.difficultyDropdown.options[this.difficultyDropdown.value].text;
        GameMetricLogger.SetGameLogger(GameLoggerOptions.StartGameMetrics);
    }
Ejemplo n.º 6
0
    public void TurnOffLANClientMenu()
    {
        this.initialMenu.SetActive(false);
        this.optionsMenu.SetActive(false);
        this.unitAttributeEditor.SetActive(false);
        this.LANHost.SetActive(false);
        this.LANClientReady.SetActive(false);
        this.LANClientNotReady.SetActive(false);
        this.LANClientNotConnected.SetActive(false);
        //EnableAttributeEditor enableEditorObj = this.optionsMenu.GetComponentInChildren<EnableAttributeEditor>();
        //if (enableEditorObj != null) {
        //	enableEditorObj.TurnOffCanvasGroup();
        //}

        GameMetricLogger.SetGameLogger(GameLoggerOptions.GameIsPlaying);
    }
Ejemplo n.º 7
0
        public void CmdUpdateStatus(bool targetEnemyIsGone, Color recoveryColor)
        {
            if (this.currentHealth <= 0)
            {
                if (this.gameObject != null)
                {
                    GameMetricLogger.Increment(GameMetricOptions.Death);

                    RpcUnitDestroy(this.gameObject);
                }
            }
            else
            {
                RpcUpdateStatus(targetEnemyIsGone, recoveryColor);
            }
        }
Ejemplo n.º 8
0
/***
 *    ███████╗███╗   ██╗██████╗      ██████╗  █████╗ ███╗   ███╗███████╗
 *    ██╔════╝████╗  ██║██╔══██╗    ██╔════╝ ██╔══██╗████╗ ████║██╔════╝
 *    █████╗  ██╔██╗ ██║██║  ██║    ██║  ███╗███████║██╔████╔██║█████╗
 *    ██╔══╝  ██║╚██╗██║██║  ██║    ██║   ██║██╔══██║██║╚██╔╝██║██╔══╝
 *    ███████╗██║ ╚████║██████╔╝    ╚██████╔╝██║  ██║██║ ╚═╝ ██║███████╗
 *    ╚══════╝╚═╝  ╚═══╝╚═════╝      ╚═════╝ ╚═╝  ╚═╝╚═╝     ╚═╝╚══════╝
 *
 */

    public void SetEndGameSession()
    {
        //if (!(this.endGameMenu.activeSelf || this.endGameMenu.activeInHierarchy)) {
        //}

        //this.endGameMenu.SetActive(true);
        this.initialMenu.SetActive(false);
        this.optionsMenu.SetActive(false);
        this.LANClientNotConnected.SetActive(false);
        this.LANClientNotReady.SetActive(false);
        this.LANClientReady.SetActive(false);
        this.LANHost.SetActive(false);
        this.unitAttributeEditor.SetActive(false);

        GameMetricLogger.SetGameLogger(GameLoggerOptions.StopGameMetrics);
        GameMetricLogger.ShowPrintLog();
    }
Ejemplo n.º 9
0
        public void AttackAI(GameObject victim, float attackCounter)
        {
            if (victim == null)
            {
                return;
            }
            AIUnit victimUnit = victim.GetComponent <AIUnit>();

            if (victimUnit != null)
            {
                victimUnit.TakeDamage(this.attackPower);
                this.attackCooldownCounter = attackCounter;

                if (victimUnit.currentHealth <= 0)
                {
                    GameMetricLogger.Increment(GameMetricOptions.Kills);
                }
            }
        }
Ejemplo n.º 10
0
        private bool HandleStatus()
        {
            //Returns TRUE if the game unit is destroyed, preventing all other actions from executing.
            //Returns FALSE if game unit is alive.

            if (this.properties.currentHealth <= 0 && !this.isDead)
            {
                this.isDead = true;
                GameMetricLogger.Increment(GameMetricOptions.Death);
                CmdDestroy(this.gameObject);
                return(true);
            }
            if (this.properties.isAttackCooldownEnabled)
            {
                if (this.attackCooldownCounter > 0)
                {
                    this.attackCooldownCounter -= Time.deltaTime;

                    GameMetricLogger.Increment(GameMetricOptions.BattleEngagementTime);
                }
                else
                {
                    NewChanges changes = this.CurrentProperty();
                    changes.isAttackCooldownEnabled = false;
                    this.NewProperty(changes);
                }
            }
            if (this.properties.isRecoveryEnabled)
            {
                if (this.recoveryCounter > 0f)
                {
                    this.recoveryCounter -= Time.deltaTime / 5f;
                }
                else
                {
                    NewChanges changes = this.CurrentProperty();
                    changes.isRecoveryEnabled = false;
                    this.NewProperty(changes);
                }
            }
            return(false);
        }
Ejemplo n.º 11
0
        private void UpdateMergeGroups()
        {
            //This follows the same code design pattern used in Split Manager. It's a very stable way of cleaning/updating the lists
            //this manager manages.
            if (this.mergeList.Count > 0)
            {
                for (int i = 0; i < this.mergeList.Count; i++)
                {
                    MergeGroup group = this.mergeList[i];
                    if (group.elapsedTime > 1f)
                    {
                        group.Resume();
                        if (!this.removeList.Contains(group))
                        {
                            FinishMergeGroup(group);
                            this.removeList.Add(group);

                            GameMetricLogger.Increment(GameMetricOptions.Merges);
                        }
                    }
                    else
                    {
                        group.Update(this.scalingValue);
                        group.elapsedTime += Time.deltaTime / group.mergeSpeedFactor;
                        this.mergeList[i]  = group;
                    }
                }
            }

            if (this.removeList.Count > 0)
            {
                foreach (MergeGroup group in this.removeList)
                {
                    if (this.mergeList.Contains(group))
                    {
                        this.mergeList.Remove(group);
                    }
                }
                this.removeList.Clear();
            }
        }
Ejemplo n.º 12
0
    public void StopLANClient()
    {
        if (NetworkClient.active)
        {
            this.networkManager.StopClient();
        }
        this.LANClientReady.SetActive(false);
        this.LANClientNotReady.SetActive(false);
        this.LANClientNotConnected.SetActive(false);
        this.initialMenu.SetActive(true);
        this.optionsMenu.SetActive(true);
        EnableAttributeEditor enableEditorObj = this.optionsMenu.GetComponentInChildren <EnableAttributeEditor>();

        if (enableEditorObj != null && enableEditorObj.isCustomOptionSelected)
        {
            enableEditorObj.TurnOnCanvasGroup();
        }

        GameMetricLogger.DisableLoggerHotkey();
        GameMetricLogger.SetGameLogger(GameLoggerOptions.GameIsOver);
    }
Ejemplo n.º 13
0
    //NOTE(Thompson): This is equivalent to SetClientReady().
    public void SetLANHostReady()
    {
        this.LANHost.SetActive(false);

        GameMetricLogger.EnableLoggerHotkey();

        PostRenderer renderer = Camera.main.GetComponent <PostRenderer>();

        if (renderer != null)
        {
            renderer.enabled = true;
        }

        Canvas         canvas = GameObject.FindObjectOfType <Canvas>();
        TooltipLocator loc    = canvas.GetComponent <TooltipLocator>();

        if (loc != null)
        {
            loc.tooltip.SetToolTipHidden(true);
        }
    }
Ejemplo n.º 14
0
        private void HandleAttacking()
        {
            if (this.properties.targetUnit != null && this.attackCooldownCounter <= 0 && !this.properties.isAttackCooldownEnabled)
            {
                CmdAttack(this.hasAuthority, this.gameObject, this.properties.targetUnit, 1);
                this.attackCooldownCounter = 1f;
                NewChanges changes = this.CurrentProperty();
                changes.isAttackCooldownEnabled = true;
                this.NewProperty(changes);

                GameMetricLogger.Increment(GameMetricOptions.Attacks);
            }
            else if (this.attackCooldownCounter > 0f)
            {
                NewChanges changes = this.CurrentProperty();
                changes.isAttackCooldownEnabled = true;
                this.NewProperty(changes);

                GameMetricLogger.Increment(GameMetricOptions.AttackTime);
            }
        }
Ejemplo n.º 15
0
    public void StopLANHost()
    {
        //NOTE(Thompson): This is the official method of resetting the LAN session if the
        //player wants to play a new LAN session after ending a previous LAN session.
        SceneManager.LoadScene("new_multiplayer");

        //NOTE(Thompson): When reloading a scene, the GUIs are not reset to its initial states. Therefore
        //the following reinitialization codes are necessary.
        this.networkManager.StopHost();
        this.LANHost.SetActive(false);
        this.LANClientReady.SetActive(false);
        this.LANClientNotReady.SetActive(false);
        this.LANClientNotConnected.SetActive(false);
        this.initialMenu.SetActive(true);
        this.optionsMenu.SetActive(true);
        EnableAttributeEditor enableEditorObj = this.optionsMenu.GetComponentInChildren <EnableAttributeEditor>();

        if (enableEditorObj != null && enableEditorObj.isCustomOptionSelected)
        {
            enableEditorObj.TurnOnCanvasGroup();
        }

        MinimapStuffs stuffs = GameObject.FindObjectOfType <MinimapStuffs>();

        if (stuffs != null)
        {
            stuffs.playerCameraPanning = Camera.main.GetComponent <CameraPanning>();
            Camera minimapCamera = stuffs.GetComponent <Camera>();
            minimapCamera.enabled = false;
        }

        if (Taskbar.Instance != null)
        {
            Taskbar.Instance.ShowTaskbar(false);
        }

        GameMetricLogger.DisableLoggerHotkey();
        //GameMetricLogger.SetGameLogger(GameLoggerOptions.StopGameMetrics);
    }
Ejemplo n.º 16
0
    private void PreUnitAttributesInitialization()
    {
        GameObject obj = GameObject.Find("Temporary Unit Attributes");

        if (obj == null)
        {
            obj = this.temporaryUnitAttributesObject;
        }
        if (obj != null)
        {
            UnitAttributes myAttributes         = null;
            GameObject[]   playerUnitAttributes = GameObject.FindGameObjectsWithTag("UnitAttributes");
            for (int i = 0; i < playerUnitAttributes.Length; i++)
            {
                NetworkIdentity identity = playerUnitAttributes[i].GetComponent <NetworkIdentity>();
                if (identity.hasAuthority)
                {
                    myAttributes = playerUnitAttributes[i].GetComponent <UnitAttributes>();
                    UnitAttributes tempAttr = obj.GetComponent <UnitAttributes>();
                    myAttributes.CopyFrom(tempAttr);
                    break;
                }
            }
            if (myAttributes != null)
            {
                GameObject[] gameUnits = GameObject.FindGameObjectsWithTag("Unit");
                foreach (GameObject unit in gameUnits)
                {
                    NetworkIdentity identity = unit.GetComponent <NetworkIdentity>();
                    if (identity != null && identity.hasAuthority)
                    {
                        GameUnit gameUnit = unit.GetComponent <GameUnit>();
                        gameUnit.unitAttributes = myAttributes;
                    }
                }
            }
            GameMetricLogger.SetGameLogger(GameLoggerOptions.GameIsPlaying);
        }
    }
Ejemplo n.º 17
0
    public void SetClientReady()
    {
        if (!ClientScene.ready)
        {
            if (ClientScene.Ready(this.networkManager.client.connection))
            {
                Camera       cam      = Camera.main.GetComponent <Camera>();
                PostRenderer renderer = cam.GetComponent <PostRenderer>();
                if (renderer != null)
                {
                    renderer.enabled = true;
                }
                MinimapStuffs stuffs = GameObject.FindObjectOfType <MinimapStuffs>();
                if (stuffs != null)
                {
                    Camera minimapCamera = stuffs.GetComponent <Camera>();
                    minimapCamera.enabled      = true;
                    stuffs.playerCameraPanning = Camera.main.GetComponent <CameraPanning>();
                }
                this.LANClientReady.SetActive(false);
                this.LANClientNotReady.SetActive(false);

                GameMetricLogger.EnableLoggerHotkey();

                NewSpawner[] spawners = GameObject.FindObjectsOfType <NewSpawner>();
                foreach (NewSpawner spawn in spawners)
                {
                    if (spawn != null && spawn.hasAuthority)
                    {
                        NewSpawner.Instance.CmdSetReadyFlag(ClientScene.ready && !NetworkServer.active);
                    }
                }

                GameMetricLogger.SetGameLogger(GameLoggerOptions.StartGameMetrics);
            }
            else
            {
                this.LANClientReady.SetActive(false);
                this.LANClientNotReady.SetActive(true);
            }
            if (ClientScene.localPlayers.Count == 0)
            {
                ClientScene.AddPlayer(0);
            }
        }
        else
        {
            this.LANClientReady.SetActive(false);
            this.LANClientNotReady.SetActive(false);

            Camera       cam      = Camera.main.GetComponent <Camera>();
            PostRenderer renderer = cam.GetComponent <PostRenderer>();
            if (renderer != null)
            {
                renderer.enabled = true;
            }
            MinimapStuffs stuffs = GameObject.FindObjectOfType <MinimapStuffs>();
            if (stuffs != null)
            {
                Camera minimapCamera = stuffs.GetComponent <Camera>();
                minimapCamera.enabled      = true;
                stuffs.playerCameraPanning = Camera.main.GetComponent <CameraPanning>();
            }

            this.LANClientReady.SetActive(false);
            this.LANClientNotReady.SetActive(false);

            string name = this.playerNameField.text;
            if (name.Length > 0)
            {
                GameMetricLogger.instance.playerName = name;
            }
            else
            {
                GameMetricLogger.instance.playerName = "Player";
            }
            GameMetricLogger.instance.difficultyEquations = this.difficultyDropdown.options[this.difficultyDropdown.value].text;
            GameMetricLogger.EnableLoggerHotkey();

            NewSpawner[] spawners = GameObject.FindObjectsOfType <NewSpawner>();
            foreach (NewSpawner spawn in spawners)
            {
                if (spawn != null && spawn.hasAuthority)
                {
                    NewSpawner.Instance.CmdSetReadyFlag(ClientScene.ready && !NetworkServer.active);
                }
            }

            GameMetricLogger.SetGameLogger(GameLoggerOptions.StartGameMetrics);
        }

        Canvas         canvas = GameObject.FindObjectOfType <Canvas>();
        TooltipLocator loc    = canvas.GetComponent <TooltipLocator>();

        if (loc != null)
        {
            loc.tooltip.SetToolTipHidden(true);
        }
    }
Ejemplo n.º 18
0
    public void SingleStartHost()
    {
        DropdownFix[] fixes  = GameObject.FindObjectsOfType <DropdownFix>();
        int           values = 0;

        for (int i = 0; i < fixes.Length; i++)
        {
            values += fixes[i].value;
        }
        if (values <= 0)
        {
            //Start Game button is now interactable only when player hasn't chosen a preset.
            return;
        }
        //Note(Thompson): Player is always index 1.
        //Note(Thompson): Obtain the A.I. level difficulty.
        GameMetricLogger.instance.levelDifficulty = fixes[0].value;
        //Note(Thompson): Check if the Player dropdown value is 5. If not, and is above 0, return difficulty equation used. Else, return a full range of custom equations used.
        GameMetricLogger.SetDifficultyEquation(ConvertCustomToEquations(fixes[1].value, fixes[1].options[fixes[1].value].text));
        GameMetricLogger.SetPlayerName("Player");


        if (this.attributePanelGroup != null)
        {
            this.attributePanelGroup.alpha          = 0f;
            this.attributePanelGroup.blocksRaycasts = false;
            this.attributePanelGroup.interactable   = false;
        }

        GameObject minimapCameraObject = GameObject.FindGameObjectWithTag("Minimap");
        Camera     minimapCamera       = minimapCameraObject.GetComponent <Camera>();

        if (minimapCamera != null && !minimapCamera.enabled)
        {
            minimapCamera.enabled = true;
        }

        if (this.playerObject != null)
        {
            this.playerObject.SetActive(true);
        }

        if (this.AIPlayer != null)
        {
            //AI attribute manager.
            AIAttributeManager attributeManager = this.AIPlayer.GetComponentInChildren <AIAttributeManager>();
            if (attributeManager != null)
            {
                Debug.Log("It works!");
            }

            //AI Unit spawning.
            GameObject obj = MonoBehaviour.Instantiate(this.AIUnitPrefab) as GameObject;
            obj.transform.SetParent(this.AIUnits.transform);
            obj.transform.position = this.GetStartPosition().position;
            AIUnit unit = obj.GetComponent <AIUnit>();

            //AI manager spawning.
            AIManager AImanager = this.AIPlayer.GetComponentInChildren <AIManager>();
            if (AImanager != null)
            {
                unit.unitManager = AImanager;

                if (attributeManager != null && attributeManager.attributePanelUI != null)
                {
                    DifficultyGroup group = attributeManager.attributePanelUI.aiCalibrationDifficulty;
                    AImanager.UpdateDifficulty(group.GetDifficulty());
                }

                unit.SetTeam(AImanager.teamFaction);
                AImanager.Activate();
            }
        }

        this.playerUmbrellaObject = GameObject.FindGameObjectWithTag("Player");
        if (this.playerUmbrellaObject != null)
        {
            this.HumanPlayer = this.playerUmbrellaObject;
            Transform unitUmbrellaTransform = this.playerUmbrellaObject.transform.GetChild(0);
            this.HumanUnits = unitUmbrellaTransform.gameObject;
        }

        SetupPlayerUnits();

        if (!this.isNetworkActive)
        {
            this.StartHost();
        }

        this.enablePauseGameMenu = true;
        this.notReady            = false;

        if (Taskbar.Instance != null)
        {
            Taskbar.Instance.ShowTaskbar(true);
        }

        GameMetricLogger.SetGameLogger(GameLoggerOptions.StartGameMetrics);
        GameMetricLogger.SetGameLogger(GameLoggerOptions.GameIsPlaying);
        GameMetricLogger.EnableLoggerHotkey();
    }
Ejemplo n.º 19
0
        private void ManageLists()
        {
            if (this.splitList.Count > 0)
            {
                for (int i = this.splitList.Count - 1; i >= 0; i--)
                {
                    Split splitGroup = this.splitList[i];
                    if (splitGroup.owner == null || splitGroup.split == null)
                    {
                        this.splitList.Remove(splitGroup);
                    }
                    if (splitGroup.elapsedTime > 1f)
                    {
                        NewGameUnit unit = splitGroup.owner.GetComponent <NewGameUnit>();
                        this.changes             = unit.CurrentProperty();
                        this.changes.isSelected  = false;
                        this.changes.isSplitting = false;
                        CmdUpdateUnitProperty(splitGroup.owner.gameObject, this.changes);
                        unit = splitGroup.split.GetComponent <NewGameUnit>();
                        CmdUpdateUnitProperty(splitGroup.split.gameObject, this.changes);
                        this.unitList.Add(new NewUnitStruct(splitGroup.split.gameObject));
                        this.splitList.Remove(splitGroup);

                        GameMetricLogger.Increment(GameMetricOptions.Splits);
                    }
                    else
                    {
                        splitGroup.Update();
                        this.splitList[i] = splitGroup;
                    }
                }
            }
            if (this.mergeList.Count > 0)
            {
                for (int i = this.mergeList.Count - 1; i >= 0; i--)
                {
                    Merge mergeGroup = this.mergeList[i];
                    if (mergeGroup.elapsedTime > 1f)
                    {
                        if (mergeGroup.owner != null)
                        {
                            NewGameUnit unit = mergeGroup.owner.gameObject.GetComponent <NewGameUnit>();
                            this.changes            = unit.CurrentProperty();
                            this.changes.isMerging  = false;
                            this.changes.isSelected = false;
                            //changes.newLevel = unit.properties.level + 1;
                            CmdUpdateUnitProperty(mergeGroup.owner.gameObject, this.changes);
                        }
                        if (mergeGroup.merge != null)
                        {
                            NewUnitStruct temp = new NewUnitStruct();
                            temp.unit = mergeGroup.merge.gameObject;
                            this.unitList.Remove(temp);
                            CmdDestroy(temp.unit);
                        }
                        this.mergeList.RemoveAt(i);

                        GameMetricLogger.Increment(GameMetricOptions.Merges);
                    }
                    else
                    {
                        mergeGroup.Update();
                        this.mergeList[i] = mergeGroup;
                    }
                }
            }
            this.isUnitListEmpty = this.unitList.Count <= 0;
            if (!this.isUnitListEmpty)
            {
                for (int i = this.unitList.Count - 1; i >= 0; i--)
                {
                    if (this.unitList[i].unit == null)
                    {
                        this.unitList.RemoveAt(i);
                        continue;
                    }
                    NetworkIdentity id = this.unitList[i].unit.GetComponent <NetworkIdentity>();
                    if (!id.hasAuthority)
                    {
                        CmdRemoveUnitList(this.unitList[i].unit);
                    }
                }
            }
            else
            {
                CmdShowReport();
            }
        }
Ejemplo n.º 20
0
 private void LogKill()
 {
     GameMetricLogger.Increment(GameMetricOptions.Kills);
 }
Ejemplo n.º 21
0
        void Update()
        {
            if (!this.hasAuthority)
            {
                return;
            }
            if (this.minimapCamera == null)
            {
                return;
            }
            if (this.allObjects.Count <= 0)
            {
                if (!this.isDead)
                {
                    GameMetricLogger.ShowPrintLog();
                    AIManager.Instance.startAIFlag = false;
                    this.isDead = true;
                }
                return;
            }

            //This handles all the input actions the player has done in the minimap.
            this.screenPoint = Camera.main.ScreenToViewportPoint(Input.mousePosition);
            if (this.minimapCamera.rect.Contains(this.screenPoint) && Input.GetMouseButtonDown(1))
            {
                if (this.selectedObjects.Count > 0)
                {
                    float   mainX = (this.screenPoint.x - this.minimapCamera.rect.xMin) / (1.0f - this.minimapCamera.rect.xMin);
                    float   mainY = (this.screenPoint.y) / (this.minimapCamera.rect.yMax);
                    Vector3 minimapScreenPoint = new Vector3(mainX, mainY, 0f);
                    foreach (GameObject obj in this.selectedObjects)
                    {
                        GameUnit unit = obj.GetComponent <GameUnit>();
                        if (unit != null)
                        {
                            unit.CastRay(true, minimapScreenPoint, this.minimapCamera);
                        }
                    }
                }
            }
            else
            {
                if (this.minimapCamera.rect.Contains(this.screenPoint))
                {
                    return;
                }
                //This handles all the input actions the player has done to box select in the game.
                //Currently, it doesn't handle clicking to select.
                if (Input.GetMouseButtonDown(0))
                {
                    if (!(Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)))
                    {
                        ClearSelectObjects();
                    }
                    this.isSelecting  = true;
                    this.initialClick = Input.mousePosition;
                }
                else if (Input.GetMouseButtonUp(0))
                {
                    if (!(Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)))
                    {
                        ClearSelectObjects();
                    }
                    SelectObjectAtPoint();
                    SelectObjectsInRect();
                    SelectObjects();
                    this.isSelecting    = false;
                    this.isBoxSelecting = false;
                    this.initialClick   = -Vector3.one * 9999f;
                }
            }

            if (this.isSelecting && Input.GetMouseButton(0))
            {
                if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
                {
                    this.isBoxSelecting = true;
                }
                this.selectionBox.Set(this.initialClick.x, Screen.height - this.initialClick.y, Input.mousePosition.x - this.initialClick.x, (Screen.height - Input.mousePosition.y) - (Screen.height - this.initialClick.y));
                if (this.selectionBox.width < 0)
                {
                    this.selectionBox.x     += this.selectionBox.width;
                    this.selectionBox.width *= -1f;
                }
                if (this.selectionBox.height < 0)
                {
                    this.selectionBox.y      += this.selectionBox.height;
                    this.selectionBox.height *= -1f;
                }
                TempRectSelectObjects();
            }

            foreach (GameObject obj in this.allObjects)
            {
                if (obj == null && !this.removeList.Contains(obj))
                {
                    this.removeList.Add(obj);
                }
            }

            for (int i = 0; i < this.selectedObjects.Count; i++)
            {
                if (this.selectedObjects[i] == null)
                {
                    this.selectedObjects.RemoveAt(i);
                }
            }

            if (this.removeList.Count > 0)
            {
                foreach (GameObject obj in this.removeList)
                {
                    if (this.allObjects.Contains(obj))
                    {
                        this.allObjects.Remove(obj);
                    }
                }
                foreach (GameObject obj in this.removeList)
                {
                    CmdDestroy(obj);
                }
                this.removeList.Clear();
            }
        }
Ejemplo n.º 22
0
        public void Update()
        {
            if (this.unitCount <= 0 && !this.startAIFlag && this.isSingleAIPlayer && this.hasLostTheGame)
            {
                if (!GameMetricLogger.instance.isShownToScreen)
                {
                    GameMetricLogger.ShowPrintLog();
                }
                return;
            }

            if (this.splitGroupList.Count > 0)
            {
                for (int i = 0; i < this.splitGroupList.Count; i++)
                {
                    SplitGroup splitGroup = this.splitGroupList[i];
                    if (splitGroup.elapsedTime > 1f)
                    {
                        this.splitGroupList.RemoveAt(i);
                        i--;
                    }
                    else
                    {
                        splitGroup.Update();
                        splitGroup.elapsedTime += Time.deltaTime;
                        this.splitGroupList[i]  = splitGroup;
                    }
                }
            }
            if (this.mergeGroupList.Count > 0)
            {
                for (int i = 0; i < this.mergeGroupList.Count; i++)
                {
                    MergeGroup mergeGroup = this.mergeGroupList[i];
                    if (mergeGroup.elapsedTime > 1f)
                    {
                        if (mergeGroup.owner != null)
                        {
                            AIUnit unit = mergeGroup.owner.GetComponent <AIUnit>();
                            unit.previousLevel = unit.level;
                            unit.level++;

                            //TODO: Use the attribute manager to manage the attributes after merging.
                            TierUpgrade tier = this.aiAttributeManager.tiers[unit.level - 1];

                            //float temp = unit.currentHealth;
                            unit.currentHealth = (int)tier.health;                          // (temp * tier.health);
                            //temp = unit.maxHealth;
                            unit.maxHealth = (int)tier.health;                              //(temp * tier.health);

                            unit.attackFactor         = tier.attack;
                            unit.mergeFactor          = tier.merge;
                            unit.attackCooldownFactor = tier.attackCooldown;
                            unit.splitFactor          = tier.split;
                            unit.mergeFactor          = tier.merge;
                            unit.speedFactor          = tier.speed;
                        }
                        if (mergeGroup.merge != null)
                        {
                            this.removeUnitList.Add(mergeGroup.merge.GetComponent <AIUnit>());
                        }
                        //MonoBehaviour.Destroy(mergeGroup.merge);
                        this.mergeGroupList.RemoveAt(i);
                        i--;
                    }
                    else
                    {
                        mergeGroup.Update();
                        mergeGroup.elapsedTime += Time.deltaTime;
                        this.mergeGroupList[i]  = mergeGroup;
                    }
                }
            }
            if (this.removeUnitList.Count > 0)
            {
                foreach (AIUnit unit in this.removeUnitList)
                {
                    if (unit != null)
                    {
                        MonoBehaviour.Destroy(unit.gameObject);
                    }
                }
                this.removeUnitList.Clear();
            }
            this.unitCount = this.unitContainer.transform.childCount;
        }