Example #1
0
    public void Possess(AbstractLivingBeing argBeing)
    {
        /*if (argBeing.name == "Squirrel")
        {
            SquirrelClimb climbScript = argBeing.GetComponent<SquirrelClimb>();
            climbScript.setControlled(argBeing.name);
        }*/

        DisablePlayerControl();
        argBeing.EnablePlayerControl();

        Transform.position -= Vector3.up * 60;
    }
Example #2
0
    public IEnumerator StartNewFight(AbstractBeing argEntity, AbstractLivingBeing argFightableObject)
    {
        SetUpAnims();
        bool complete = false;
        int finished = 0;
        int step = 0;
        var quicktime = argFightableObject.GameObject.RequireComponentAdd<Quicktime>();

        theTarget = argEntity;

        gameObject.RequireComponentAdd<AutonomousVehicle>();
        predSteer = gameObject.RequireComponentAdd<SteerForPursuit>();
        predSteer.Quarry = argEntity.gameObject.RequireComponentAdd<AutonomousVehicle>();
        predSteer.enabled = true;
        ////debug.log("Enable chase");

        while (complete == false)
        {

            // Remove Energy if Failed
            //if (finished == 3)
            //Ghost.Animation.Blend(AnimationResources.PossWrongInput);

            // Fail Entirely only if No EnergyLeft);

            if (MainPlayerGhost.Instance.Energy <= 0)
            {
                complete = true;
                argEntity.Animation.Stop();
                argEntity.Animation.CrossFade(AnimationResources.Death);
                AbstractAnimal abAnimal = argEntity as AbstractAnimal;
                abAnimal._isDead = 1;
                abAnimal.AnimalSoundtrack.playDeath();
                StartCoroutine(MainPlayerGhost.Instance.PossessionRemote.TurnOff(argEntity));
            }

            // If Not Complete Run Quicktime Event
            if (!complete)
            {
                if (predSteer.enabled == false)
                {
                    switch (step)
                    {
                        case 0:
                            argFightableObject.Animation.CrossFade(AnimationResources.AttackDance);
                            argEntity.Animation.CrossFade(AnimationResources.Freeze);
                            break;
                    }
                    step++;
                    yield return StartCoroutine(quicktime.Fire());

                    finished = quicktime.Status;
                    if (finished == 2 && step != 0)
                    {
                        dodgeOrHit = 0;
                        totalWins++;
                        argFightableObject.Animation.Stop();
                        argFightableObject.Animation.Play(AnimationResources.Attack);

                        AbstractAnimal abAnimal = argFightableObject as AbstractAnimal;
                        abAnimal.AnimalSoundtrack.playBattle();
                    }
                    else if (finished == 3 && step != 0)
                    {
                        dodgeOrHit = 1;
                        argFightableObject.Animation.Stop();
                        argFightableObject.Animation.Play(AnimationResources.Attack);

                        AbstractAnimal abAnimal = argFightableObject as AbstractAnimal;
                        abAnimal.AnimalSoundtrack.playBattle();
                    }

                    argFightableObject.Animation.CrossFadeQueued(AnimationResources.AttackDance);

                    if (totalWins >= winsNeededToEscape)
                    {
                        complete = true;
                        timeUntilActive = Time.time + restTime;
                        argEntity.EnablePlayerControl();
                        SteerForPursuit steer = this.gameObject.GetComponent<SteerForPursuit>();

                        quicktime.Stop();
                        steer.enabled = false;
                        totalWins = 0;
                        fightIsOn = 0;
                    }
                }
                else
                {
                    yield return new WaitForFixedUpdate();
                }
            }
        }
        yield return new WaitForFixedUpdate();
    }
Example #3
0
    private IEnumerator PossessionStruggle(AbstractLivingBeing argEntity)
    {
        bool complete = false;
        int status = 0;
        int step = 0;
        Quicktime quicktime = argEntity.GameObject.RequireComponentAdd<Quicktime>();
        ParticleAnimator prefab = ResourceManager.ParticleResources["SequenceEmitter_Glow"];
        ParticleAnimator particle = Instantiate(prefab) as ParticleAnimator;
        particle.transform.position = argEntity.Transform.position;
        particle.transform.rotation = argEntity.Transform.rotation;
        particle.transform.parent = argEntity.Transform;

        AbstractAnimal argAnimal = argEntity as AbstractAnimal;
        if (argAnimal != null)
            argAnimal.AnimalSoundtrack.playPossession();

        Ghost.Animation[AnimationResources.PossBegin].speed = 1.5f;
        argEntity.animation[AnimationResources.PossBegin].speed = 1.5f;
        Ghost.Animation.CrossFade(AnimationResources.PossBegin);
        yield return new WaitForSeconds(2);

        while (complete == false)
        {
            // If Not Complete Run Quicktime Event
            if (!complete)
            {
                ////debug.log("FIRE: " + Time.time);
                yield return StartCoroutine(quicktime.Fire());
                while (Ghost.Animation.IsPlaying(AnimationResources.PossBegin))
                    yield return new WaitForFixedUpdate();
                status = quicktime.Status;
                step++;
                ////debug.log("ANIMATE: " + Time.time);
            }

            string animationName = "";
            switch (step)
            {
                case 1: animationName = AnimationResources.PossInput1;  break;
                case 2: animationName = AnimationResources.PossInput2; break;
                case 3: animationName = AnimationResources.PossInput3; break;
                case 4: animationName = AnimationResources.PossInput4; break;
                case 5: complete = true; break;
            }

            // Fail Entirely only if No EnergyLeft);
            if (Ghost.Energy <= 0)
            {
                complete = true;
                Ghost.Animation.CrossFade(AnimationResources.PossFail);
                Target.animation.CrossFade(AnimationResources.PossFail);
            }

            // Animate Action
            if (animationName != "")
            {
                Ghost.Animation.CrossFade(animationName + "A");
            }

            // Shoot Beams
            if (animationName != "")
            {
                if (step != 0) StartCoroutine(FireRope(status != 3, argEntity as AbstractLivingBeing, animationName));
            }

            // Wait For Animation Complete

        }

        // Animate Pull
        yield return new WaitForSeconds(0.3f); // Wait for Rotation Complete
        Ghost.animation.CrossFade(AnimationResources.PossWrongInput);
        yield return new WaitForSeconds(0.3f);
        argEntity.animation[AnimationResources.PossComplete].speed = 2;
        argEntity.animation.CrossFade(AnimationResources.PossComplete);
        yield return new WaitForSeconds(0.3f);
        _NeedRopes = false;

        // Rotate Target
        Ghost.Animation.CrossFade(AnimationResources.PossInput4Idle);
        yield return StartCoroutine(Target.RotateTowards(Target.Transform.position + Ghost.Transform.forward, 3));

        // Jump Into Target
        Ghost.Animation.CrossFade(AnimationResources.PossComplete);

        Destroy(particle.gameObject);

        yield return new WaitForFixedUpdate();
    }
Example #4
0
 public void Unpossess(AbstractLivingBeing argBeing)
 {
     EnablePlayerControl();
     argBeing.DisablePlayerControl();
     Transform.position = argBeing.Transform.position + (Vector3.up * 0.6f);
     Transform.LookAt(argBeing.Transform);
 }
Example #5
0
    public IEnumerator FireRope(bool correct, AbstractLivingBeing argBeing, string animationName)
    {
        while (Ghost.Animation.IsPlaying(animationName + "A"))
            yield return new WaitForFixedUpdate();
        Ghost.Animation.CrossFade(animationName + "B");

        _NeedRopes = true;
        GameObject _Rope = GameObject.CreatePrimitive(PrimitiveType.Sphere);
        GameObject.Destroy(_Rope.collider);
        _Rope.renderer.material.shader = Shader.Find("Transparent/Shield");
        _Rope.renderer.material.color = new Color(0.6f, 0.8f, 1f, 0.1f);

        float time = 0;
        float speed = 3f;

        Transform start = null, end = null;
        switch (_Ropes.Count)
        {
            case 0: start = Ghost.RightHand; end = argBeing.LeftHand; break;
            case 1: start = Ghost.LeftHand; end = argBeing.RightHand; break;
            case 2: start = Ghost.LeftHand; end = argBeing.RightFoot; break;
            case 3: start = Ghost.RightHand; end = argBeing.LeftFoot; break;
        }

        ParticleAnimator prefab = correct ? ResourceManager.ParticleResources["SequenceEmitter_Correct"] : ResourceManager.ParticleResources["SequenceEmitter_Wrong"];
        ParticleAnimator instance = Instantiate(prefab) as ParticleAnimator;
        instance.transform.position = start.position;
        instance.transform.rotation = start.rotation;

        _Ropes.Add(_Rope);

        while (_NeedRopes)
        {
            time += Time.deltaTime;

            /// Scale Size to Distance
            float size = 0.03f;
            float dist = Mathf.Lerp(0, Vector3.Distance(start.position, end.position), time * speed);
            _Rope.transform.localScale = new Vector3(size, dist, size);

            /// Find Center
            _Rope.transform.position = Vector3.Lerp(start.position, (start.position + end.position) / 2, time * speed);

            /// Look At Target
            _Rope.transform.LookAt(end.position);
            _Rope.transform.Rotate(Vector3.right * 90); // Offset

            yield return new WaitForFixedUpdate();
        }

        // Break Ropes
        foreach(GameObject obj in _Ropes)
            GameObject.Destroy(obj);
    }