Exemplo n.º 1
0
    public override void Action()
    {
        if (!triggerActionStateOnce)
        {
            Debug.Log("SpecialAbility: " + this.GetAnimationStateName() + " is in action state");
            //Play the animation

            //Generate the Grappler entity
            AbilityEntity entity = Instantiate(this.abilityEntitites[0], agent.transform.position, agent.transform.rotation);

            //Attach the entity to the player so that it moves with the player
            entity.transform.parent = agent;

            entity.SetAgent(agent);

            //Ensure the grapple point looks at the center of the screen.
            Camera cam = GetAgent().GetComponent <ThirdPersonMovement>().cam.GetComponent <Camera>();
            //entity.GetComponent<GrapplerAbilityEntity>().GrappleTip.LookAt(GetAgent().GetComponent<ThirdPersonMovement>().cam.GetComponent<Camera>().ScreenToWorldPoint(new Vector3(cam.pixelWidth/2, cam.pixelHeight/2, 0)));

            //Ensure the Grapple tip looks forward at the center of the screen
            entity.GetComponent <GrapplerAbilityEntity>().GrappleTip.LookAt(cam.transform.forward);

            //Ensure the ability entity is connected to the object the player's reticle is currently aiming at
            try
            {
                entity.GetComponent <GrapplerAbilityEntity>().ConnectedObject = agent.GetComponent <ThirdPersonMovement>().aimReticle.GetComponent <Reticle>().Target.transform;
            }
            catch (System.Exception)
            {
                Debug.Log("Reticle is not looking at a target: destroy this ability");
                //Ensure the entity resets player controls
                entity.GetComponent <GrapplerAbilityEntity>().GetGrapple().ResetPlayer();
                Destroy(entity.gameObject);
                Destroy(this.gameObject);
            }

            //Grab the Target that is connected to the grappler. This target is originally defined by the Reticle

            /*if(entity.GetComponent<GrapplerAbilityEntity>().ConnectedObject != null)
             * {
             *  agent.GetComponent<ThirdPersonMovement>().EngageDynamicTargetLock(entity.GetComponent<GrapplerAbilityEntity>().ConnectedObject);
             * }*/

            //Turn off character controller & Turn the rigid body on
            agent.GetComponent <ThirdPersonMovement>()._controller.enabled = false;
            agent.GetComponent <ThirdPersonMovement>().moveCharacter       = false;
            agent.GetComponent <ThirdPersonMovement>().togglePlayerMovementControl(false);
            agent.GetComponent <ThirdPersonMovement>().applyGravity = false;
            agent.GetComponent <Rigidbody>().isKinematic            = false;
            agent.GetComponent <RigidbodyCharacter>().enabled       = true;

            //Proceed to the next animation
            ActivateActionStateOnce();
        }
    }
Exemplo n.º 2
0
    public override void Action()
    {
        if (!triggerActionStateOnce)
        {
            Debug.Log("SpecialAbility: " + this.GetAnimationStateName() + " is in action state");
            //Play the animation

            //Generate the overskin
            AbilityEntity entity = Instantiate(this.abilityEntitites[0], agent.transform.position, agent.transform.rotation);

            //Set entity's agent property
            entity.SetAgent(this.agent);

            //Attach the overskin to the player so that it moves with the player
            entity.transform.parent = agent;

            //Have the player affected by gravity again.
            agent.GetComponent <ThirdPersonMovement>().SetPlayerGravity(true);

            //Proceed to the next animation
            ActivateActionStateOnce();
        }
    }