Пример #1
0
        private static IEnumerator DelayCoroutine(int frames, CoroutineData <int> f)
        {
            for (var n = 0; n < frames; ++n)
            {
                yield return(null);
            }

            f.Invoke();

            while (true)
            {
                if (f.queue.Count != 0)
                {
                    for (int i = 0; i < f.currentAction.value1; i++)
                    {
                        yield return(null);
                    }
                    f.Dequeue();
                    f.Invoke();
                }
                else
                {
                    f.Dispose();
                    break;
                }
            }
        }
Пример #2
0
    public void StartCoroutine(IEnumerator coroutine)
    {
        CoroutineData coroutineData = new CoroutineData();

        coroutineData.m_coroutine = coroutine;
        m_coroutineList.Add(coroutineData);
    }
Пример #3
0
        public int StartCoroutine(IEnumerator functionCall)
        {
            var data = new CoroutineData(nextID++, functionCall);

            coroutineList.Add(data);
            return(data.ID);
        }
Пример #4
0
    public void init()
    {
        infiniteObjectGenerator           = InfiniteObjectGenerator.instance;
        powerUpManager                    = PowerUpManager.instance;
        gameManager                       = GameManager.instance;
        projectionCamerasController       = ProjectionCamerasController.instance;
        projectionPortalWindowsController = ProjectionPortalWindowsController.instance;
//		mainCameraController = MainCameraController.instance;

        platformLayer = LayerMask.NameToLayer("Platform");
        wallLayer     = LayerMask.NameToLayer("Wall");
        obstacleLayer = LayerMask.NameToLayer("Obstacle");

        thisTransform   = transform;
        thisRigidbody   = rigidbody;
        capsuleCollider = GetComponent <CapsuleCollider>();
        playerAnimation = GetComponent <PlayerAnimation>();
        playerAnimation.init();

        startPosition = thisTransform.position;
        startRotation = thisTransform.rotation;

        slideData = new CoroutineData();
        forwardSpeeds.init();

        // make sure the coin magnet trigger is deactivated
        activatePowerUp(PowerUpTypes.CoinMagnet, false, Color.white);

        reset();
        enabled = false;
//		zorbModeActive = false;
    }
    public void LerpOverTime(CoroutineData _coroutineData, float _duration, AnimationCurve _curve = null,
                             bool _ignoreTimeScale = false, CoroutineCheckMethod _checkMethod = CoroutineCheckMethod.StopExistingRoutine)
    {
        switch (_checkMethod)
        {
        default:
        case CoroutineCheckMethod.StopExistingRoutine:

            if (Coroutines.ContainsKey(_coroutineData.Key))
            {
                if (Coroutines[_coroutineData.Key].Routine != null)
                {
                    StopCoroutine(Coroutines[_coroutineData.Key].Routine);
                }
                Coroutines.Remove(_coroutineData.Key);
            }

            Coroutines.Add(_coroutineData.Key, _coroutineData);

            StartCoroutine(IELerpOverTime(_coroutineData, _duration, _curve, _ignoreTimeScale));

            break;

        case CoroutineCheckMethod.WaitForExistingRoutine:

            if (!Coroutines.ContainsKey(_coroutineData.Key))
            {
                Coroutines.Add(_coroutineData.Key, _coroutineData);
                _coroutineData.Routine = StartCoroutine(IELerpOverTime(_coroutineData, _duration, _curve, _ignoreTimeScale));
            }

            break;
        }
    }
Пример #6
0
    public IEnumerator StartPlayerTurn()
    {
        // TODO activate all OnPlayerTurnStart effects:
        // player, skills, and enemies

        // Draw a card
        CoroutineData DrawingCard = new CoroutineData(this, DrawTopCardFromDeck());

        // Wait for Card to be finished drawing
        yield return(DrawingCard.coroutine);

        string DrawingCoroutine = null;

        DrawingCoroutine = (string)DrawingCard.result;

        yield return(new WaitUntil(() => DrawingCoroutine == "Finished"));

        // Resolve player on turn start effects
        Player.StartPlayerTurn();

        // Allow user input
        InputController.PlayerInputPermission = true;


        yield return(null);
    }
Пример #7
0
        public static CoroutineData <int> Delay(this MonoBehaviour g, int frames, Action f)
        {
            var coroutineData = new CoroutineData <int>(f, frames);

            g.StartCoroutine(DelayCoroutine(frames, coroutineData));
            return(coroutineData);
        }
Пример #8
0
        public static CoroutineData <float> Delay(this MonoBehaviour g, float seconds, Action f)
        {
            var coroutineData = new CoroutineData <float>(f, seconds);

            g.StartCoroutine(DelayCoroutine(seconds, coroutineData));
            return(coroutineData);
        }
Пример #9
0
    /// <summary>
    /// Let the user select a target
    /// </summary>
    /// <returns></returns>
    private IEnumerator SelectOrigin()
    {
        while (true)
        {
            if (Input.GetMouseButtonDown(0))
            {
                var mousePosition = new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x,
                                                Camera.main.ScreenToWorldPoint(Input.mousePosition).y);
                var hitCollider = Physics2D.OverlapPoint(mousePosition);
                if (hitCollider && hitCollider.tag == "Player")
                {
                    var selec = _entityBattleInfos.First(e => e.Source.Name == hitCollider.gameObject.name);

                    //Choose the skill you want to execute
                    var selecSkill = new CoroutineData <Skill>(this, selec.Source.ChoosePlayerSkill());
                    yield return(selecSkill.Coroutine);

                    selec.Skill = selecSkill.Result;

                    // Choose the target for your skill
                    yield return(SelecTarget(selec));

                    yield return(selec);

                    yield break;
                }
            }

            yield return(null);
        }
    }
Пример #10
0
        private void Step(CoroutineData coroutineData)
        {
            var coroutine = coroutineData.Value;

            coroutine.Continue();
            ProcessCoroutineStep(coroutineData);
        }
Пример #11
0
 public void Start()
 {
     playerTransform = PlayerController.instance.transform;
     pool            = new List <ProjectileObject>();
     poolIndex       = 0;
     fireTime        = -reloadTime;
     fireData        = new CoroutineData();
 }
Пример #12
0
	public void Start()
    {
        playerTransform = PlayerController.instance.transform;
        pool = new List<ProjectileObject>();
        poolIndex = 0;
        fireTime = -reloadTime;
        fireData = new CoroutineData();
	}
Пример #13
0
    void Start()
    {
        gameManager = GameManager.instance;
        dataManager = DataManager.instance;
        GameManager.instance.onPauseGame += gamePaused;

        activePowerUp     = PowerUpTypes.None;
        activePowerUpData = new CoroutineData();
    }
Пример #14
0
	public void Start()
	{
        gameManager = GameManager.instance;
		dataManager = DataManager.instance;
        gameManager.onPauseGame += gamePaused;	
	
		activePowerUp = PowerUpTypes.None;
		activePowerUpData = new CoroutineData();
	}
Пример #15
0
    public IEnumerator PlayCard(GameObject pCard)
    {
        // Get the card_data
        Card_Data tCardData = pCard.GetComponent <CardController> ().Card;

        // Remove the card from the hand
        CardsInHand.Remove(pCard);

        // Pay the cost of the card
        Player.PayManaCost(tCardData.manaCost);

        // TODO Check effects that activate on card activation

        // Toss the card template back to factory
        StartCoroutine(MatchHelper.RecycleCardTemplate(pCard));

        // Set card being play
        CardBeingPlay = tCardData;

        // Get all the effects of the card
        List <_Effect> tEffects = pCard.GetComponent <CardController>().GetEffects();

        // Resolve the card effects
        for (int i = 0; i < tEffects.Count; i++)
        {
            string        Result;
            CoroutineData EffectCoroutine = new CoroutineData(this, tEffects [i].ResolveEffect());

            yield return(EffectCoroutine.coroutine);

            Result = null;
            Result = (string)EffectCoroutine.result;

            yield return(new WaitUntil(() => Result == "Finished"));
        }

        // Decrement card_data charge
        tCardData.charge--;
        Debug.Log("Charge: " + tCardData.charge);

        // Put the card back into the deck or discard pile
        if (tCardData.charge > 0)
        {
            Deck.AddCardToDeck(tCardData);
        }
        else
        {
            DiscardPile.Add(tCardData);
        }

        AlignHand();
        CardBeingPlay = null;
        yield return("Finished");
    }
    public void LerpOverTime(string _key, float _duration, UnityAction <float> _onUpdate, UnityAction _onStart = null, UnityAction _onFinished = null, AnimationCurve _curve = null,
                             bool _ignoreTimeScale = false, CoroutineCheckMethod _checkMethod = CoroutineCheckMethod.StopExistingRoutine)
    {
        CoroutineData _coroutineData = new CoroutineData();

        _coroutineData.Key        = _key;
        _coroutineData.OnStart    = _onStart;
        _coroutineData.OnUpdate   = _onUpdate;
        _coroutineData.OnFinished = _onFinished;

        LerpOverTime(_coroutineData, _duration, _curve, _ignoreTimeScale, _checkMethod);
    }
Пример #17
0
        private static CoroutineData GetOrRegisterCoroutineEvent(object owner)
        {
            CoroutineData data;

            if (!generatorData.coroutineEvent.TryGetValue(owner, out data))
            {
                data = new CoroutineData();
                data.variableName = "coroutine" + (++coNum).ToString();
                generatorData.coroutineEvent[owner] = data;
            }
            return(data);
        }
Пример #18
0
    public IEnumerator AddBlockToPlayer(int pBlock)
    {
        string Result;

        CoroutineData tCoroutine = new CoroutineData(this, Player.AddBlock(pBlock));

        yield return(tCoroutine.coroutine);

        Result = null;
        Result = (string)tCoroutine.result;

        yield return(new WaitUntil(() => Result == "Finished"));

        yield return("Finished");
    }
Пример #19
0
    public IEnumerator DealDamageToPlayer(int pDamage)
    {
        string Result;

        CoroutineData tCoroutine = new CoroutineData(this, Player.AttackedForValue(pDamage));

        yield return(tCoroutine.coroutine);

        Result = null;
        Result = (string)tCoroutine.result;

        yield return(new WaitUntil(() => Result == "Finished"));

        yield return("Finished");
    }
Пример #20
0
    public IEnumerator PerformCoroutine(IEnumerator pCoroutine)
    {
        string Result;

        CoroutineData tCoroutine = new CoroutineData(this, pCoroutine);

        yield return(tCoroutine.coroutine);

        Result = null;
        Result = (string)tCoroutine.result;

        yield return(new WaitUntil(() => Result == "Finished"));

        yield return("Finished");
    }
Пример #21
0
    /// <summary>
    /// 添加协同委托
    /// </summary>
    /// <param name="d">协同委托</param>
    public void AddCoroutine(CoroutineDelegate d)
    {
        if (d == null)
        {
            return;
        }

        var data = new CoroutineData
        {
            Destroyed = false,
            Handler   = d
        };

        _coroutineData.Add(data);
    }
    public IEnumerator ActivateSkillEffects()
    {
        string Result;

        CoroutineData EffectCoroutine = new CoroutineData(this, mSkillEffects[Random.Range(0, mSkillEffects.Count)].ResolveEffect());

        yield return(EffectCoroutine.coroutine);

        Result = null;
        Result = (string)EffectCoroutine.result;

        yield return(new WaitUntil(() => Result == "Finished"));

        yield return("Finished");
    }
Пример #23
0
    public IEnumerator DrawTopCardFromDeck()
    {
        // Set magnify on hover off
        InputController.CanMagnify = false;
        InputController.UnmagnifyCard();

        string Result;

        // Get the card_data from the deck
        Card_Data tCardData = Deck.DrawTopCard();

        // Wait until the deck return a card_data
        yield return(new WaitUntil(() => tCardData != null));

        // Set the card data into a template
        GameObject tCard = null;

        tCard = MatchHelper.SetCardData(tCardData);

        yield return(new WaitUntil(() => tCard != null));

        // Show the card draw from the top of the deck
        CoroutineData DrawingCoroutine = new CoroutineData(this, MatchHelper.RenderCardFromDeck(tCard));

        // Wait for Card to be drew from the deck
        yield return(DrawingCoroutine.coroutine);

        Result = null;
        Result = (string)DrawingCoroutine.result;

        yield return(new WaitUntil(() => Result == "Finished"));

        // Put the card in the player hand
        CoroutineData PutCardInHandCoroutine = new CoroutineData(this, PutCardInHand(tCard));

        yield return(PutCardInHandCoroutine.coroutine);

        Result = null;
        Result = (string)PutCardInHandCoroutine.result;

        yield return(new WaitUntil(() => Result == "Finished"));

        // Set magnify on hover on
        InputController.CanMagnify = true;

        yield return("Finished");
    }
    public IEnumerator IELerpOverTime(CoroutineData _coroutineData, float _duration, AnimationCurve _curve = null, bool _ignoreTimeScale = false)
    {
        if (_coroutineData.OnStart != null)
        {
            _coroutineData.OnStart.Invoke();
        }

        if (_curve == null)
        {
            _curve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);
        }


        float _lerpTime = 0f;

        while (_lerpTime < 1f)
        {
            float _time = _ignoreTimeScale ? Time.unscaledDeltaTime : Time.deltaTime;   //fix dit door er monobehaviour van te maken i guess?
            _lerpTime += _time / _duration;

            float _evaluatedLerpTime = _curve.Evaluate(_lerpTime);

            if (_coroutineData.OnUpdate != null)
            {
                _coroutineData.OnUpdate.Invoke(_evaluatedLerpTime);
            }
            yield return(null);
        }

        if (_coroutineData.OnUpdate != null)
        {
            _coroutineData.OnUpdate.Invoke(1f);
        }
        if (_coroutineData.OnFinished != null)
        {
            _coroutineData.OnFinished.Invoke();
        }

        if (Coroutines.ContainsKey(_coroutineData.Key))
        {
            Coroutines.Remove(_coroutineData.Key);
        }

        yield return(null);
    }
Пример #25
0
    public override IEnumerator ResolveEffect()
    {
        int tBlock = mMatchController.CardBeingPlay.block;
        PlayerCharacterController tPlayer = mMatchController.Player;

        string Result;

        CoroutineData GainBlockCoroutine = new CoroutineData(mMatchController, tPlayer.AddBlock(tBlock));

        yield return(GainBlockCoroutine.coroutine);

        Result = null;
        Result = (string)GainBlockCoroutine.result;

        yield return(new WaitUntil(() => Result == "Finished"));

        yield return("Finished");
    }
Пример #26
0
    public IEnumerator StartMatch()
    {
        for (int i = 0; i < 3; i++)
        {
            // Draw a card
            CoroutineData DrawingCard = new CoroutineData(this, DrawTopCardFromDeck());

            // Wait for Card to be finished drawing
            yield return(DrawingCard.coroutine);

            string DrawingCoroutine = null;
            DrawingCoroutine = (string)DrawingCard.result;

            yield return(new WaitUntil(() => DrawingCoroutine == "Finished"));
        }

        StartCoroutine("StartPlayerTurn");
    }
    public IEnumerator ActivateOnTurnStartEffects()
    {
        string Result;

        for (int i = 0; i < OnHitEffects.Count; i++)
        {
            CoroutineData EffectCoroutine = new CoroutineData(this, mOnTurnStartEffects[i].ResolveEffect());

            yield return(EffectCoroutine.coroutine);

            Result = null;
            Result = (string)EffectCoroutine.result;

            yield return(new WaitUntil(() => Result == "Finished"));
        }

        yield return("Finished");
    }
    /// <summary>
    /// Recycles the card template.
    /// </summary>
    /// <param name="pCard">P card.</param>
    public IEnumerator RecycleCardTemplate(GameObject pCard)
    {
        string Result;

        CoroutineData MovingCoroutine = new CoroutineData(this, MoveCardToGrave(pCard));

        // Wait for Card to be drew from the deck
        yield return(MovingCoroutine.coroutine);

        Result = null;
        Result = (string)MovingCoroutine.result;

        yield return(new WaitUntil(() => Result == "Finished"));

        // Recycle the card
        CardFactory.RecycleCardTemplate(pCard);

        yield return("Finished");
    }
Пример #29
0
    public override IEnumerator ResolveEffect()
    {
        int        tDamage = mMatchController.CardBeingPlay.damage;
        GameObject tTarget = mMatchController.TargetEnemy;

        string Result;

        CoroutineData AttackCoroutine = new CoroutineData(mMatchController, tTarget.GetComponent <EnemyController> ().AttackedForValue(tDamage));

        yield return(AttackCoroutine.coroutine);

        Result = null;
        Result = (string)AttackCoroutine.result;

        yield return(new WaitUntil(() => Result == "Finished"));


        yield return("Finished");
    }
Пример #30
0
    public IEnumerator AttackedForValue(int pDamage)
    {
        string Result;

        Debug.Log("Player taking damage: " + pDamage);

        // TODO activate all OnHitEffects
        CoroutineData EffectCoroutine = new CoroutineData(this, ActivateOnHitEffects());

        yield return(EffectCoroutine.coroutine);

        Result = null;
        Result = (string)EffectCoroutine.result;

        yield return(new WaitUntil(() => Result == "Finished"));

        Debug.Log("Player start health: " + Health);

        // Deal damage to block value first
        if (Block >= pDamage)
        {
            Block -= pDamage;
            RenderBlock();
        }
        else
        {
            // Deal the damage
            Health -= (pDamage - Block);
            Block   = 0;
            RenderHealth();
            RenderBlock();
        }

        if (IsDead())
        {
            mMatchController.RemoveEnemy(gameObject);
        }


        yield return("Finished");
    }
    public override IEnumerator ResolveEffect()
    {
        int tDamage = mMatchController.EnemyActing.Damage;

        Debug.Log("Enemy damage: " + tDamage);
        PlayerCharacterController tPlayer = mMatchController.Player;

        string Result;

        CoroutineData AttackCoroutine = new CoroutineData(mMatchController, tPlayer.AttackedForValue(tDamage));

        yield return(AttackCoroutine.coroutine);

        Result = null;
        Result = (string)AttackCoroutine.result;

        yield return(new WaitUntil(() => Result == "Finished"));


        yield return("Finished");
    }
        void DoFixedUpdateCoroutine(CoroutineData r)
        {
            if (r.enumerator.Current is WaitForFixedUpdate)
            {
                // FIXME
                Debug.Log("FixedUpdate coroutines don't yet work correctly");

                bool ended = r.enumerator.MoveNext();
                if (r.reachedEnd == true && r.lastYielded == r.enumerator.Current)
                {
                    routines.Remove(r);
                    return;
                }

                if (ended == true)
                {
                    r.reachedEnd  = true;
                    r.lastYielded = r.enumerator.Current;
                }
            }
        }
 internal void StartPseudoCoroutine(object sender, IEnumerator routine)
 {
     var r = new CoroutineData (routine);
     routines.Add (r);
 }
        void DoUpdateCoroutine(CoroutineData r)
        {
            bool ended;

            // FIXME too much copy/pasting between blocks

            // WaitForSeconds
            if (r.enumerator.Current is WaitForSeconds) {
                // Wait
                if (r.timeRemaining == null) {
                    WaitForSeconds s = (WaitForSeconds)r.enumerator.Current;
                    FieldInfo f = s.GetType ().GetField ("m_Seconds", BindingFlags.NonPublic | BindingFlags.Instance);
                    // FIXME accumulates error over time, slightly slower than a normal coroutine
                    r.timeRemaining = (float)f.GetValue (s) - Time.deltaTime;
                    ended = false;
                    return;
                }
                else if (r.timeRemaining <= 0) {
                    r.timeRemaining = null;
                    ended = r.enumerator.MoveNext ();
                    if (r.reachedEnd == true && r.lastYielded == r.enumerator.Current) {
                        routines.Remove (r);
                        return;
                    }
                }
                else {
                    r.timeRemaining -= Time.deltaTime;
                    return;
                }
            }
            // WaitForEndOfFrame
            else if (r.enumerator.Current is WaitForEndOfFrame) {
                ended = r.enumerator.MoveNext ();
                if (r.reachedEnd == true && r.lastYielded == r.enumerator.Current) {
                    routines.Remove (r);
                    return;
                }
            }
            // Coroutine
            else if (r.enumerator.Current is Coroutine) {
                // FIXME implement this! How do we figure out if a coroutine has finished? Bypass for now.
                Debug.LogWarning("Yielding on a Coroutine is not yet implemented in ManagerWrangler");
                ended = r.enumerator.MoveNext ();
                if (r.reachedEnd == true && r.lastYielded == r.enumerator.Current) {
                    routines.Remove (r);
                    return;
                }
            }
            else {
                ended = r.enumerator.MoveNext ();
                if (r.reachedEnd == true && r.lastYielded == r.enumerator.Current) {
                    routines.Remove (r);
                    return;
                }
            }

            if (ended == true) {
                r.reachedEnd = true;
                r.lastYielded = r.enumerator.Current;
            }
        }
        void DoFixedUpdateCoroutine(CoroutineData r)
        {
            if (r.enumerator.Current is WaitForFixedUpdate) {

                // FIXME
                Debug.Log ("FixedUpdate coroutines don't yet work correctly");

                bool ended = r.enumerator.MoveNext ();
                if (r.reachedEnd == true && r.lastYielded == r.enumerator.Current) {
                    routines.Remove (r);
                    return;
                }

                if (ended == true) {
                    r.reachedEnd = true;
                    r.lastYielded = r.enumerator.Current;
                }
            }
        }
Пример #36
0
	public void Start ()
	{
        gameManager = GameManager.instance;
		dataManager = DataManager.instance;
        missionManager = MissionManager.instance;
        coinGUICollection = CoinGUICollection.instance;
		
		guiState = GUIState.MainMenu;
        inGamePowerUpData = new CoroutineData();
        gameManager.onPauseGame += gamePaused;	

		// hide everything except the main menu
#if UNITY_3_5
        mainMenuPanel.SetActiveRecursively(true);
        logoPanel.SetActiveRecursively(true);
        inGameLeftPanel.SetActiveRecursively(false);
		inGameTopPanel.SetActiveRecursively(false);
		inGameRightPanel.SetActiveRecursively(false);
		endGamePanel.SetActiveRecursively(false);
        storePanel.SetActiveRecursively(false);
		statsPanel.SetActiveRecursively(false);
        missionsPanel.SetActiveRecursively(false);
        pausePanel.SetActiveRecursively(false);
        tutorialPanel.SetActiveRecursively(false);
#else
        InfiniteRunnerStarterPackUtility.ActiveRecursively(mainMenuPanel.transform, true);
        InfiniteRunnerStarterPackUtility.ActiveRecursively(logoPanel.transform, true);
        InfiniteRunnerStarterPackUtility.ActiveRecursively(inGameLeftPanel.transform, false);
        InfiniteRunnerStarterPackUtility.ActiveRecursively(inGameTopPanel.transform, false);
        InfiniteRunnerStarterPackUtility.ActiveRecursively(inGameRightPanel.transform, false);
        InfiniteRunnerStarterPackUtility.ActiveRecursively(endGamePanel.transform, false);
        InfiniteRunnerStarterPackUtility.ActiveRecursively(storePanel.transform, false);
        InfiniteRunnerStarterPackUtility.ActiveRecursively(statsPanel.transform, false);
        InfiniteRunnerStarterPackUtility.ActiveRecursively(missionsPanel.transform, false);
        InfiniteRunnerStarterPackUtility.ActiveRecursively(pausePanel.transform, false);
        InfiniteRunnerStarterPackUtility.ActiveRecursively(tutorialPanel.transform, false);
#endif
    }
Пример #37
0
 public int StartCoroutine(IEnumerator functionCall)
 {
     var data = new CoroutineData(nextID++, functionCall);
     coroutineList.Add(data);
     return data.ID;
 }
Пример #38
0
    public void init()
    {
        // deprecated variables warnings:
        if (jumpForce != 0 && jumpHeight == 0) {
            Debug.LogError("PlayerController.jumpForce is deprecated. Use jumpHeight instead.");
            jumpHeight = jumpForce;
        }
        if (jumpDownwardForce != 0 && gravity == 0) {
            Debug.LogError("PlayerController.jumpDownwardForce is deprecated. Use gravity instead.");
            gravity = jumpDownwardForce;
        }
        // rigidbody should no longer use gravity, be kinematic, and freeze all constraints
        if (rigidbody != null) {
            if (rigidbody.useGravity) {
                Debug.LogError("The rigidbody no longer needs to use gravity. Disabling.");
                rigidbody.useGravity = false;
            }
            if (!rigidbody.isKinematic) {
                Debug.LogError("The rigidbody should be kinematic. Enabling.");
                rigidbody.isKinematic = true;
            }
            if (rigidbody.constraints != RigidbodyConstraints.FreezeAll) {
                Debug.LogError("The rigidbody should freeze all constraints. The PlayerController will take care of the physics.");
                rigidbody.constraints = RigidbodyConstraints.FreezeAll;
            }
        }

        cameraController = CameraController.instance;
        infiniteObjectGenerator = InfiniteObjectGenerator.instance;
        powerUpManager = PowerUpManager.instance;
        gameManager = GameManager.instance;
        if (attackType == AttackType.Projectile) {
            projectileManager = GetComponent<ProjectileManager>();
        }

        platformLayer = 1 << LayerMask.NameToLayer("Platform");
        floorLayer = 1 << LayerMask.NameToLayer("Floor");
        wallLayer = LayerMask.NameToLayer("Wall");
        obstacleLayer = LayerMask.NameToLayer("Obstacle");

        thisTransform = transform;
        capsuleCollider = GetComponent<CapsuleCollider>();
        playerAnimation = GetComponent<PlayerAnimation>();
        playerAnimation.init();

        startPosition = thisTransform.position;
        startRotation = thisTransform.rotation;

        slideData = new CoroutineData();
        stumbleData = new CoroutineData();
        forwardSpeeds.init();
        // determine the fastest and the slowest forward speeds
        forwardSpeeds.getMinMaxValue(out minForwardSpeed, out maxForwardSpeed);
        forwardSpeedDelta = maxForwardSpeed - minForwardSpeed;
        if (forwardSpeedDelta == 0) {
            playerAnimation.setRunSpeed(1, 1);
        }

        // make sure the coin magnet trigger is deactivated
        activatePowerUp(PowerUpTypes.CoinMagnet, false);

        reset();
        enabled = false;
    }