Esempio n. 1
0
        public override bool Activate()
        {
            if (AgentComponent.ActivateAgentSkill(this))
            {
                AgentComponent.SetVelocityY(JumpPower);
                AgentComponent.DeactivateAgentSkill(this);
                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        /// <summary>
        /// Activate the skill and begin any sort of animations or movements.
        /// </summary>
        public override bool Activate()
        {
            if (m_colliedWall && AgentComponent.ActivateAgentSkill(this))
            {
                m_rigidbody2D.drag = 1f;
                AgentComponent.SetVelocityY(JumpPower);
                AgentComponent.DeactivateAgentSkill(this);
                m_colliedWall = false;

                return(true);
            }

            return(base.Activate());
        }
Esempio n. 3
0
        /// <summary>
        /// The grow coroutine in which transform the sphere
        /// into titan form.
        /// </summary>
        ///
        /// <returns>The coroutine.</returns>
        private IEnumerator growCoroutine()
        {
            // Get the offset of y in the titan form
            float   yOffset           = (Size / 4f) - 0.25f;
            Vector2 titanFormPosition = transform.position + new Vector3(0f, yOffset, 0f);

            // Create a circle to detect if the are any object that would prevent the sphere from transforming
            // If the colliders array is NOT empty, it means the sphere might not be able to transform
            Collider2D[] colliders = Physics2D.OverlapCircleAll(titanFormPosition, Size / 4f, Layers);

            if (colliders.Length > 0)
            {
                // Get the "ground" object by raycasting directly down
                RaycastHit2D raycast = Physics2D.Raycast(titanFormPosition, Vector2.down, Mathf.Infinity, Layers);

                foreach (Collider2D collider in colliders)
                {
                    // Do not transform if the collider is not a "ground" collider or if the normal
                    // vector is not pointing up
                    if (collider != raycast.collider || raycast.normal != Vector2.up)
                    {
                        if (!m_errorCoroutineRunning)
                        {
                            StartCoroutine(displayErrorCoroutine());
                        }

                        AgentComponent.DeactivateAgentSkill(this);
                        yield break;
                    }
                }
            }

            AgentComponent.Invicible = true;
            m_isActive = true;
            AgentComponent.AttackerComponent.AttackDamage = AttackDamage;
            m_particleSystem.Emit(ParticleCount);

            transform.localScale *= Size;
            transform.position    = titanFormPosition;
            m_rigidbody2D.mass    = Mass;

            // Play the titan form audio clip
            m_audioSource.clip = TitanAudioClip;
            m_audioSource.Play();

            yield return(new WaitForSeconds(2.0f));

            Cancel();
        }
Esempio n. 4
0
        public override bool Cancel()
        {
            Debug.Log("Attempt to cancel Rocket Drill");
            bool result = AgentComponent.DeactivateAgentSkill(this);

            if (result == true)
            {
                m_isActive = false;
                AgentComponent.AttackerComponent.AttackDamage = AgentComponent.AttackerComponent.DefaultAttackDamage;

                // Return to the idle animation
                m_animator.SetInteger("RocketDrill", 0);
            }

            return(result);
        }
Esempio n. 5
0
        /// <summary>
        /// Deactivate the skill and stop the player during the skill executation
        /// or when the skill is done executing.
        /// </summary>
        public override bool Cancel()
        {
            // Prevent accidental shrinking beyond the original size
            if (m_originalScale != transform.localScale)
            {
                AgentComponent.Invicible = false;

                m_isActive = false;
                AgentComponent.SetVelocity(0f, 0f);
                AgentComponent.AttackerComponent.AttackDamage = AgentComponent.AttackerComponent.DefaultAttackDamage;
                transform.localScale /= Size;
                m_rigidbody2D.mass    = m_originalMass;
            }

            return(AgentComponent.DeactivateAgentSkill(this));
        }
Esempio n. 6
0
        public override bool Cancel()
        {
            if (m_isActive)
            {
                bool result = AgentComponent.DeactivateAgentSkill(this);
                if (result == true)
                {
                    m_isActive = false;
                    AgentComponent.AttackerComponent.AttackDamage = AgentComponent.AttackerComponent.DefaultAttackDamage;

                    // Set velocity to 0 to reduce the chances of cube
                    // falling through the ground or platforms
                    AgentComponent.SetVelocity(0f, 0f);

                    // Play the stomp audio
                    m_audioSource.clip = StompAudio;
                    m_audioSource.Play();
                }

                return(result);
            }
            return(false);
        }
Esempio n. 7
0
        public override bool Cancel()
        {
            if (m_isActive)
            {
                Debug.Log("GLIDE STOP");
                bool result = AgentComponent.DeactivateAgentSkill(this);
                if (result == true)
                {
                    m_isActive = false;

                    // Revert the gravity scale and linear drag to default values
                    m_rigidbody2D.gravityScale = 1f;
                    m_rigidbody2D.drag         = 0f;
                }

                // Stop playing the Glide animation and stop the audio from looping
                m_animator.SetInteger("Glide", 0);
                m_audioSource.loop = false;

                return(result);
            }
            return(false);
        }