예제 #1
0
        void LateUpdate()
        {
            // If currently in Cloning state, assume the Clone Menu is open
            if (mainCell.vars.activeState == State.CLONING)
            {
                if (player.GetButtonDown("CreateClone"))
                {
                    mainCell.ChangeState(State.CONTROL);
                }
                if (mainCell.player.GetButtonDown("Confirm") && cloneMenu.CanSelectClone())
                {
                    CreateClone(cloneMenu.CreateClone());
                }
            }
            else if (mainCell.vars.activeState == State.CONTROL && mainCell.vars.activeClones < 5 && mainCell.vars.maxHealth >= 40)
            {
                if (player.GetButtonDown("CreateClone"))
                {
                    EnterCloneMenu();
                }
            }

            if (mainCell.vars.activeClones > 0 &&
                currentActive.vars.grounded && currentActive.vars.activeState == State.CONTROL)
            {
                if (player.GetButtonDown("SwapCloneRight"))
                {
                    SwitchClone(true);
                }
                else if (player.GetButtonDown("SwapCloneLeft"))
                {
                    SwitchClone(false);
                }
            }

            if (mainCell.vars.activeClones > 0 && currentActive.vars.isClone && player.GetButtonDown("KillClone"))
            {
                if (currentActive.vars.isGateClone)
                {
                    if ((currentActive.vars.isOnGate && mainCell.vars.isOnGate) || IsInRangeOfCell())
                    {
                        DestroyActiveClone();
                    }
                }
                else
                {
                    DestroyActiveClone();
                }
            }
            if (mainCell.vars.activeClones > 0 && currentActive.vars.isClone && currentActive.vars.isDead)
            {
                DestroyActiveClone();
            }
        }
예제 #2
0
        /// <summary>
        /// General method to creating a clone
        /// </summary>
        /// <param name="cellType">Type of clone selected from clone UI</param>
        private void CreateClone(CellType cellType)
        {
            sfx.PlaySFX(1);

            GameObject toInstantiate;

            switch (cellType)
            {
            case CellType.M_FIGHTER:
                toInstantiate = melee_fighter;
                break;

            case CellType.R_FIGHTER:
                toInstantiate = ranged_fighter;
                break;

            case CellType.JUMPER:
                toInstantiate = jumper;
                break;

            case CellType.SLINGER:
                toInstantiate = slinger;
                break;

            case CellType.GROUND:
                toInstantiate = ground;
                break;

            case CellType.NORMAL:
            default:
                toInstantiate = normal;
                break;
            }

            CellController newCell = (Instantiate <GameObject>(toInstantiate, mainCell.vars.isOnGate ? mainCell.vars.gateLocation.position + Vector3.up : mainCell.gameObject.transform.position, Quaternion.identity)).GetComponent <CellController>();

            mainCell.vars.activeClones++;

            mainCell.vars.maxHealth -= 20;
            mainCell.vars.mainHealth = mainCell.vars.mainHealth > mainCell.vars.maxHealth ?
                                       mainCell.vars.maxHealth : mainCell.vars.mainHealth;

            index = 1;
            clones.Insert(index, newCell);

            currentActive.ChangeState(State.INACTIVE);
            SetActiveAndCam(newCell);
            currentActive.vars.type = cellType;
            GivePowerups();
            currentActive.vars.isClone = true;
            UIManager.uIManager.SyncClones();
        }
예제 #3
0
 /// <summary>
 /// Shared code to set a new player/clone as the new active clone/player, manages camera, states and references.
 /// </summary>
 /// <param name="cellToActive">The player/clone to set as the new active</param>
 private void SetActiveAndCam(CellController cellToActive)
 {
     CameraManager.cameraManager.AddNewTarget(cellToActive.transform);
     cellToActive.gameObject.layer  = 13;
     currentActive.gameObject.layer = 16;
     currentActive = cellToActive;
     currentActive.ChangeState(State.CONTROL);
     UIManager.uIManager.SwitchToClone(index);
     VariableContainer.variableContainer.currentActive = currentActive;
 }