Example #1
0
    private void OnEnable()
    {
        rig = (PlayerRig)target;

        rig.alias = rig.transform.GetChild(0).GetComponent <TrackedAliasFacade>();

        rig.xrConfig      = rig.transform.GetChild(1).GetComponent <UnityXRConfigurator>();
        rig.linkedAliasXR = rig.transform.GetChild(1).GetComponent <LinkedAliasAssociationCollection>();

        rig.simFacade      = rig.transform.GetChild(2).GetComponent <SimulatorFacade>();
        rig.linkedAliasSim = rig.transform.GetChild(2).GetComponent <LinkedAliasAssociationCollection>();

        rig.leftHand  = rig.alias.LeftControllerAlias.GetComponentInChildren <InputManager>();
        rig.rightHand = rig.alias.RightControllerAlias.GetComponentInChildren <InputManager>();

        if (!System.Enum.IsDefined(typeof(InputManager.hands), rig.leftHand.handedness))
        {
            rig.leftHand.OnEnable();
        }

        if (!System.Enum.IsDefined(typeof(InputManager.hands), rig.rightHand.handedness))
        {
            rig.rightHand.OnEnable();
        }

        //if (PrefabUtility.GetPrefabType(rig.gameObject) == PrefabType.PrefabInstance)
        //{
        //	PrefabUtility.UnpackPrefabInstance(rig.gameObject, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction);
        //	return;
        //}
    }
    //private void Start()
    //{
    //	Setup(rig);
    //	UpdateVariables();
    //}


    public void Setup(PlayerRig _rig)
    {
        rig = _rig;

        switch (type)
        {
        case ComponentTypes.Walk:
            SetupWalk();
            break;

        case ComponentTypes.Teleport:
            SetupTeleport();
            break;

        case ComponentTypes.Rotate:
            SetupRotate();
            break;

        case ComponentTypes.Climb:
            SetupClimb();
            break;

        case ComponentTypes.PhysicalBody:
            SetupPhysicalBody();
            break;
        }
    }
Example #3
0
        public void OnExternalSceneLoaded(Scene scene, LoadSceneMode mode)
        {
            GameObject exitButton = Instantiate <GameObject>(exitButtonPrefab);

            exitButton.GetComponentInChildren <Button>().onClick.AddListener(() => LoadSourceScene());
            PlayerRig playerRig = FindObjectOfType <PlayerRig>();

            exitButton.transform.SetParent(playerRig.transform, false);
        }
Example #4
0
    private void Awake()
    {
        if (!rig)
        {
            rig = GetComponentInParent <PlayerRig>();
        }

        if (!rb)
        {
            rb = rig.GetComponent <Rigidbody>();
        }
        if (!col)
        {
            col = rig.GetComponent <CapsuleCollider>();
        }
    }
Example #5
0
        private void MorphUpdate(bool isMorph)
        {
            var morph = _morph;

            morph += (isMorph ? 1 : -1) * Time.deltaTime * MorphSpeed;
            morph  = Mathf.Clamp(morph, 0, 1);
            if (morph != _morph)
            {
                if (_morph == 0 && _jumpWait == 0)
                {
                    // Jump
                    _jumpWait = JumpWaitTime;
                    PlayerRig.AddForce(ToVector(_gravityDirection) * -MaxChargePower);

                    var g = Instantiate(JumpEffectPrefab, transform);
                    g.transform.SetParent(null);
                    Destroy(g.gameObject, 5);
                }

                _jumpWait = Mathf.Max(0, _jumpWait - Time.deltaTime);

                _morph = morph;
                Morph(_morph);

                if (morph == 0)
                {
                    ChangeState(PlayerState.Star);
                }
                else if (morph == 1)
                {
                    ChangeState(PlayerState.Circle);
                }
                else
                {
                    ChangeState(PlayerState.Morphing);
                }
            }
        }
Example #6
0
    public override void OnInspectorGUI()
    {
        //base.OnInspectorGUI();

        rig = (PlayerRig)target;

        if (NullRefrenceRisk())
        {
            OnEnable();
        }

        ShowHand(ref rig.leftHandOpen, rig.leftHand);
        ShowHand(ref rig.rightHandOpen, rig.rightHand);

        if (GUILayout.Button(rig.isSim ? "Simulator" : "Headset"))
        {
            rig.isSim = !rig.isSim;
            rig.SwitchRigs();
        }


        ShowPlayerComponents();
    }
Example #7
0
    public void StartLevel(TeamRoster selectedRoster)
    {
        // This oddly named object points to all sorts of useful things that exist in all levels
        instance = FindObjectOfType <PlayerRig>();

        if (instance == null)
        {
            instance = Instantiate <PlayerRig>(Core.theCore.playerRigPrefab);
            instance.transform.position = Vector3.zero;
        }

        GameObject sunObject = GameObject.Find("Directional Light");

        if (sunObject != null)
        {
            sun            = sunObject.GetComponent <Light>();
            originalSunPos = sun.transform.rotation;
        }

        instance.gameObject.SetActive(true);

        Range[] ranges = new Range[2] {
            Range.WIDE, Range.WIDE
        };

        bool bAgainstElement = false;

        fMeleeZoneSize = 1.0f;

        Core.theCore.fEnemyTimescale  = 1.0f;
        Core.theCore.fPlayerTimescale = 1.0f;

        // Spawn the player's minions immediately. Then give a countdown to start the game

        roster = selectedRoster;
        for (int i = 0; i < (int)MinionSlot.NUM_MINION_SLOTS; i++)
        {
            Transform spawnPoint = instance.playerSpawnPoints [i];
            Minion    minion     = roster.minions [i];
            if (spawnPoint != null && minion != null)
            {
                // Create new game object
                GameObject go = new GameObject("PlayerMinion_" + i + "_" + minion.template.name);

                // Fill it with actor components
                Actor_Player actor = go.AddComponent <Actor_Player>();
                actor.InitFromMinion(minion);
                actor.transform.position = spawnPoint.position;

                // Add renderer to actor
                RenderActor render = Instantiate <RenderActor>(minion.template.render);
                render.transform.SetParent(actor.transform);
                render.transform.localPosition = Vector3.zero;
                render.transform.localScale    = new Vector3(-1.0f, 1.0f, 1.0f);
                render.Init(actor);
                actor.render = render;

                // Add audio sources
                actor.soundEffect                       = go.AddComponent <AudioSource>();
                actor.soundEffect.clip                  = minion.template.soundEffect;
                actor.soundEffect.playOnAwake           = false;
                actor.soundEffect.outputAudioMixerGroup = Core.GetAudioManager().soundEffectGroup;

                // And combo numbers
                if ((minion.template.canCombo || minion.template.bDeathtoll || minion.template.bRelentless) && minion.template.comboNumbers != null)
                {
                    ComboNumbers combo = Instantiate <ComboNumbers>(minion.template.comboNumbers);
                    combo.transform.SetParent(actor.transform);
                    combo.transform.localPosition = new Vector3(-0.17f, 0.215f, -0.13f);
                    actor.comboNumbers            = combo;
                }

                // Save a reference for later
                playerActors [i] = actor;

                //
                if (((MinionSlot)i).GetSlotType() == MinionSlotType.RANGED && (minion.template is Minion_Ranged))
                {
                    ranges [i == (int)MinionSlot.RANGED_1 ? 0 : 1] = ((Minion_Ranged)minion.template).range;
                }

                if (minion.template is Minion_Support && ((Minion_Support)(minion.template)).bWalls)
                {
                    bWalls = true;
                }

                foreach (Resurrection res in minion.template.resurrectionTriggers)
                {
                    singleUseResurrections.Add(new Resurrection(res));
                }

                if (minion.template.element.GetDamageMultiplier(location.element) < 1.0f && ((MinionSlot)i).GetSlotType() != MinionSlotType.SUPPORT)
                {
                    bAgainstElement = true;
                }

                Core.theCore.fEnemyTimescale  += minion.GetBuff(Stat.ENEMY_TIMESCALE);
                Core.theCore.fPlayerTimescale += minion.GetBuff(Stat.PLAYER_TIMESCALE);

                fMeleeZoneSize += minion.GetBuff(Stat.MELEEZONE_SIZE);
            }
        }

        roster.bHasThreeResurrectsAvailable = singleUseResurrections.Count == 6;
        roster.bHasActiveCollector          = false;

        // After ALL player minions are created, then calculate their passive buffs and store them off.
        for (int i = 0; i < (int)MinionSlot.NUM_MINION_SLOTS; i++)
        {
            if (playerActors [i] != null)
            {
                playerActors [i].CalculateMyAggregateBuffs();
                playerActors [i].SetMaxHealthFromBuffs();
                playerActors [i].minion.ResetTemporaryData();
            }
        }

        roster.RecalculateHealths();

        fRangedZoneMin = Ranges.GetMinRangeForPair(ranges [0], ranges [1]);
        fRangedZoneMax = Ranges.GetMaxRangeForPair(ranges [0], ranges [1]);
        fLaneWidth     = bWalls ? 4.0f : 6.0f;
        InitZones(bWalls);

        aiNumKilledPerWave  = new int[location.numWaves];
        aiNumSpawnedPerWave = new int[location.numWaves];
        abNewlyUnlocked     = new bool[location.numWaves];


        iCurrentWave = -1;
        AdvanceWave();
        fGracePeriodDuration = location.gracePeriodDuration;

        instance.elementalHint.enabled = bAgainstElement;
        if (bAgainstElement)
        {
            instance.elementalHint.text = LocalizationManager.GetLoc(location.element.GetHintText());
        }

        Core.GetAudioManager().SetLevelMusic(location.music);

        RequestState(LevelState.PLAYING);
    }
    public static PlayerComponent CreateComponent(PlayerComponent.ComponentTypes _type, PlayerRig _rig)
    {
        var tempObject = PrefabsXR.GetPlayerComponent(_type);

        if (!tempObject)
        {
            return(null);
        }
        var instantiatedObject = Instantiate(tempObject, _rig.transform).GetComponent <PlayerComponent>();

        //var instantiatedObject = ((GameObject)PrefabUtility.InstantiatePrefab());
        instantiatedObject.Setup(_rig);
        Undo.RegisterCreatedObjectUndo(instantiatedObject.gameObject, $"Added {_type} Component");
        return(instantiatedObject);
    }