예제 #1
0
    // Takes a target and an action, checks wether anything should be triggered,
    // and triggers the appropriate event if needed.
    public static void Perform(PlayerController target, int action)
    {
        if(action == (int)actions.switchPlaces){
            if (target.IsCreator()) {
                p1_switch.set();
            }
            if (target.IsDestroyer()) {
                p2_switch.set();
            }

            // Switch their programmed positions
            if (p1_switch.get() && p2_switch.get() && Time.time > tutorialCoolDown + 1f) {
                if(Time.timeScale > 0.5 && !switch_cd.get()){
                    PlayerController.SwitchPosition();
                    switch_cd.set();
                } else if(Game.tutorialMode){
                    // If in tutorial mode, switch positions instead closes the tutorial prompt
                    Tutorial.ClearDialogue();
                }

            }

            return;
        }
        // Get section properties for the current section
        SectionProperties sp = PlayerController.CurrentSectionTransform(2).GetComponent<SectionProperties>();
        if(target.IsDriver() && target.IsCreator()){
            switch (action){
            case (int)actions.handUp: // restore floor / ceiling and supercharge.
                if(PlayerController.usableAbilities[(int)abilities.restore]){
                    sp.Restore();
                }
                else if(PlayerController.usableAbilities[(int)abilities.supercharge]){
                    sp.Supercharge();
                }
                break;
            }
        } else if(target.IsDriver() && target.IsDestroyer()){
            switch (action){
            case (int)actions.handUp: // Destroy weak object and superheat.
                if(PlayerController.usableAbilities[(int)abilities.breakobject]){
                    sp.Destroy();
                }
                else if(PlayerController.usableAbilities[(int)abilities.superheat]){
                    sp.Superheat();
                }
                break;
            }
        } else if(target.IsGunner() && target.IsCreator()){
        } else if(target.IsGunner() && target.IsDestroyer()){
        }
    }