Пример #1
0
 void Update()
 {
     if (swordState == SwordState.MOVING)
     {
         swordGO.transform.localPosition += direction * swordSpeed * Time.deltaTime;
         if (Mathf.Abs(direction.z) > 0.2f)
         {
             swordGO.transform.localRotation = Quaternion.Euler(new Vector3(0f, -90f,
                                                                            swordGO.transform.localRotation.eulerAngles.z + (direction.z * -400f * Time.deltaTime)));
         }
         else
         {
             swordGO.transform.localRotation = Quaternion.Euler(swordGO.transform.localRotation.eulerAngles +
                                                                (Vector3.forward * direction.x * -400f * Time.deltaTime));
         }
     }
     else if (swordState == SwordState.FALLING)
     {
         swordGO.transform.localPosition += Vector3.down * Time.deltaTime * swordSpeed;
     }
     else if (swordState == SwordState.IDLE)
     {
         if (!PlayerMovimentManager.HasWallInPosition(swordGO.transform.localPosition + Vector3.up * -0.2f, 0.1f) &&
             !PlayerMovimentManager.HasStairInPosition(swordGO.transform.localPosition + Vector3.up * -0.2f, 0.1f))
         {
             swordState = SwordState.FALLING;
         }
     }
     if (Vector3.Distance(swordGO.transform.localPosition, swordsContainer.transform.localPosition) > 100f)
     {
         OnSwordLeaveWorld(this);
     }
 }
Пример #2
0
    void OnCollisionEnter(Collision p_collision)
    {
        if (swordState == SwordState.IDLE || swordState == SwordState.ON_HOLD)
        {
            return;
        }

        if (p_collision.gameObject.name == "Player")
        {
            return;
        }
        else if (p_collision.gameObject.tag == "Enemy")
        {
            DropSword(p_collision.gameObject.transform.position);
            OnSwordHitEnemy(this, p_collision.gameObject.GetComponent <Enemy> ());
        }
        else if (swordState == SwordState.MOVING)
        {
            DropSword(p_collision.gameObject);
        }
        else
        {
            swordState                      = SwordState.IDLE;
            swordCollider.enabled           = true;
            swordGO.transform.localRotation = Quaternion.identity;
            if (p_collision.gameObject.tag == "Stair")
            {
                swordGO.transform.localPosition = p_collision.transform.position + (Vector3.up * 0.6f);
            }
            else
            {
                swordGO.transform.localPosition = p_collision.transform.position;
            }
        }
    }
Пример #3
0
 public Sword() : base(null, new Point(), new Vector2())
 {
     this.gravity = new Gravity(this);
     this.gravity.ChangeGravityIntensity(1.0f);
     this.SpriteFactory = EffectsFactory.GetInstance();
     this.SwordState    = new ReadyToSwingState(this);
     this.hitboxOffset  = 0;
 }
Пример #4
0
    public void BlockedBySword()
    {
        swordControl.BlockedBySword();

        motionAbsorb.weight = 0.0f;
        swordState = SwordState.Idle;
        swordCollider.enabled = false;
    }
Пример #5
0
    public void BlockedBySword()
    {
        swordControl.BlockedBySword();

        motionAbsorb.weight   = 0.0f;
        swordState            = SwordState.Idle;
        swordCollider.enabled = false;
    }
Пример #6
0
    // Update is called once per frame
    void FixedUpdate()
    {
        ApplyStateRules();


        _currState = _nextState;
        _nextState = _currState;
    }
Пример #7
0
 public void DropSword(Vector3 p_enemyPosition)
 {
     swordState                      = SwordState.IDLE;
     swordCollider.enabled           = true;
     swordGO.transform.localRotation = Quaternion.identity;
     swordGO.transform.localPosition = new Vector3(Mathf.Round(p_enemyPosition.x),
                                                   Mathf.Floor(p_enemyPosition.y), Mathf.Round(p_enemyPosition.z));
 }
Пример #8
0
 public void PlaceSwordOnPlayerHand(Transform p_playerHand)
 {
     swordState                      = SwordState.ON_HOLD;
     swordCollider.enabled           = false;
     swordGO.transform.parent        = p_playerHand;
     swordGO.transform.localPosition = Vector3.zero;
     swordGO.transform.localRotation = Quaternion.identity;
     swordGO.transform.localScale    = Vector3.one;
 }
Пример #9
0
 // Use this for initialization
 void Start()
 {
     _maximumPower     = 2;
     m_velocity        = new Vector3(0, 0, 0);
     auto              = 1;
     _noiseXCoordinate = (int)(Random.value * 3f);
     _noiseYCoordinate = (int)(Random.value * 3f);
     _currState        = SwordState.Follow;
     _nextState        = SwordState.Follow;
 }
Пример #10
0
 void ReturnDrawBack()
 {
     if (state != SwordState.ReturnDrawBack)
     {
         startTime     = Time.time;
         journeyLength = Vector3.Distance(drawbackPosition, restingPosition);
         state         = SwordState.ReturnDrawBack;
     }
     MoveSwordLerp(drawbackPosition, restingPosition, drawbackRotation, restingRotation, drawbackSpeed);
 }
Пример #11
0
 void ReturnSlice()
 {
     if (state != SwordState.ReturnSlice)
     {
         startTime     = Time.time;
         journeyLength = Vector3.Distance(slicePosition, drawbackPosition);
         state         = SwordState.ReturnSlice;
     }
     MoveSwordSlerp(slicePosition, drawbackPosition, sliceRotation, drawbackRotation, sliceSpeed);
 }
Пример #12
0
    public void ThrowSword(Player.PlayerDirection p_direction)
    {
        direction = new Vector3(Mathf.Sin((int)p_direction * -90f * Mathf.Deg2Rad),
                                0f, Mathf.Cos((int)p_direction * 90f * Mathf.Deg2Rad));

        swordGO.transform.parent        = swordsContainer.transform;
        swordGO.transform.localRotation = Quaternion.identity;
        swordGO.transform.localScale    = Vector3.one;
        swordState            = SwordState.MOVING;
        swordCollider.enabled = true;
    }
Пример #13
0
    void ReturnDefending()
    {
        if (state != SwordState.ReturnDefending)
        {
            startTime     = Time.time;
            journeyLength = Vector3.Distance(defensePosition, restingPosition);
            state         = SwordState.ReturnDefending;
        }

        MoveSwordLerp(defensePosition, restingPosition, defenseRotation, restingRotation, defenseSpeed);
    }
Пример #14
0
    // Use this for initialization
    void Start()
    {
        p1      = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();
        mainCam = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <GameCamera>();

        mySword        = transform.GetChild(0).gameObject;
        currentState   = SwordState.State1;
        previousState  = currentState;
        currentQuat    = transform.rotation;
        nextQuat       = Quaternion.Euler(rot.x, rot.y, rot.z);
        travelRotSpeed = regTravelRotSpeed;
    }
Пример #15
0
//	void Awake()
//	{
//		swordCollider = this.GetComponent<CapsuleCollider>();
//		swordRigidbody = this.GetComponent<Rigidbody>();
//
//		if (motionAbsorb == null)
//		{
//			motionAbsorb = this.GetComponent<MotionAbsorb>();
//		}
//	}

    public void Init(SwordControl swordControl)
    {
        swordCollider  = this.GetComponent <BoxCollider>();
        swordRigidbody = this.GetComponent <Rigidbody>();

        motionAbsorb      = this.GetComponent <MotionAbsorb>();
        this.swordControl = swordControl;

        motionAbsorb.weight   = 0.0f;
        swordState            = SwordState.Idle;
        swordCollider.enabled = false;
    }
Пример #16
0
    public void AddSwordToHand()
    {
        if (hand != null && sword != null)
        {
            sword.transform.SetParent(hand.transform);

            sword.transform.localRotation = new Quaternion((float)10.6, (float)-25.822, (float)20.285, (float)1.0);

            sword.transform.localPosition = new Vector3((float)0.595, (float)0.249, (float)0.212);

            swordState = SwordState.InHand;
            //  Debug.Log(sword.transform.position);
        }
    }
Пример #17
0
 private float GetRotation(SwordState state)
 {
     if (state == SwordState.Up)
     {
         return((float)(Math.PI * 1.5));
     }
     if (state == SwordState.Down)
     {
         return((float)(Math.PI * 0.5));
     }
     if (state == SwordState.Left)
     {
         return((float)(Math.PI));
     }
     return(0);
 }
Пример #18
0
    public void AddHandToBody()
    {
        if (hand != null && sword != null)
        {
            sword.transform.SetParent(hips.transform);

            sword.transform.localRotation = new Quaternion();

            sword.transform.localPosition = new Vector3((float)-1.25, (float)-0.75, (float)-8.7);

            swordState = SwordState.InBody;

            // ani.SetFloat("reverse", 1);
            //   Debug.Log(sword.transform.position);
        }
    }
Пример #19
0
    // Use this for initialization
    void Start()
    {
        restingRotation = transform.localRotation;
        restingPosition = transform.localPosition;

        drawbackRotation = Quaternion.Euler(restingRotation.eulerAngles - drawbackRotationDifference);
        drawbackPosition = restingPosition - drawbackPositionDifference;

        slicePosition = new Vector3(-drawbackPosition.x, drawbackPosition.y, drawbackPosition.z);
        sliceRotation = Quaternion.Euler(new Vector3(drawbackRotation.eulerAngles.x, 90, drawbackRotation.eulerAngles.z));

        defensePosition = new Vector3(0, restingPosition.y, restingPosition.z);
        defenseRotation = Quaternion.Euler(new Vector3(restingRotation.x, -180, -90));

        hilt          = transform.Find("Hilt").gameObject;
        tip           = transform.Find("Tip").gameObject;
        state         = SwordState.Resting;
        previousShift = false;
    }
Пример #20
0
    public void DropSword(GameObject p_hit)
    {
        swordState                      = SwordState.IDLE;
        swordCollider.enabled           = true;
        swordGO.transform.localRotation = Quaternion.identity;
        Vector3 __tempPos = swordGO.transform.localPosition - (direction * swordSpeed * Time.deltaTime);

        swordGO.transform.localPosition = new Vector3(Mathf.Round(__tempPos.x),
                                                      Mathf.Floor(__tempPos.y), Mathf.Round(__tempPos.z));

        if (p_hit.tag == "Stair")
        {
            swordGO.transform.localPosition += Vector3.up * 0.6f;
        }
        else if (!PlayerMovimentManager.HasWallInPosition(swordGO.transform.localPosition
                                                          + Vector3.up * -0.2f, 0.1f))
        {
            swordState = SwordState.FALLING;
        }
    }
Пример #21
0
    IEnumerator SwingMotion()
    {
        state = SwordState.SWINGING;

        this.renderer.enabled   = true;
        this.collider2D.enabled = true;

        float currentTime = 0.0f;

        while (state == SwordState.SWINGING)
        {
            currentTime = currentTime + Time.deltaTime;
            if (currentTime >= this.swingTime)
            {
                this.renderer.enabled   = false;
                this.collider2D.enabled = false;
                state = SwordState.STANDBY;
            }
            yield return(null);
        }
    }
Пример #22
0
 public void Block()
 {
     motionAbsorb.weight = 0.0f;
     swordState = SwordState.Block;
     swordCollider.enabled = true;
 }
Пример #23
0
 void Start()
 {
     _state = SwordState.FollowPaladin;
 }
Пример #24
0
    public void PunchUpdate()
    {
        if (Controls.GetInputDown(Controls.Type.Jump, novaPlayerScript.playerNumber) && !xa.playerHasJetpack)
        {
            storedJump = true;
        }

        switch (swordState)
        {
        case SwordState.Setup:
        {
            distSoFar            = 0;
            startPos             = transform.position;
            hitDeadlyBoxCollider = false;
            swordDir             = Vector3.zero;
            if (xa.playerControlsHeldDir < 0)
            {
                swordDir.x = -1;
            }
            if (xa.playerControlsHeldDir >= 0)
            {
                swordDir.x = 1;
            }
            swordState = SwordState.Charge;

            //play sound effect
            Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.SwordSlice);

            //ScreenSlash.ScreenSlashOn(transform.position.y);

            //previousTime = Time.timeScale;
            //Time.timeScale = timeSlowEffect;
            xa.playerAirSwording = true;
            //gotBoost = false;
            novaPlayerScript.Unstick();
        }
        break;

        case SwordState.Charge:
        {
            float dist = punchSpeed * fa.deltaTime;
            distSoFar += dist;


            //raycast for blocks

            LayerMask  swordMask = 1 << 19 | 1 << 21;                           //Only hits hitboxes on the NovaBlock layer
            Ray        ray       = new Ray();
            RaycastHit hit1      = new RaycastHit();
            RaycastHit hit2      = new RaycastHit();
            RaycastHit hit3      = new RaycastHit();
            ray.direction = swordDir;
            float   tempSpeed            = punchSpeed * fa.deltaTime;
            bool    hitSomething         = false;
            bool    raycastsHitSomething = false;
            float   half = (novaPlayerScript.plHeight * 0.5f);                          // + 0.1f;//ghx
            Vector3 v1   = Vector3.zero;
            Vector3 v2   = Vector3.zero;


            float raycastLayer = xa.GetLayer(xa.layers.RaycastLayer);
            ray.origin = new Vector3(transform.position.x, transform.position.y, raycastLayer);
            v1         = ray.origin; v1.z = 33;
            if (Physics.Raycast(ray, out hit1, dist, swordMask))
            {
                /* v2 = hit1.point; v2.z = 33; Debug.DrawLine(v1, v2, Color.yellow, 5);*/
                raycastsHitSomething = true;
            }


            ray.origin = new Vector3(transform.position.x, transform.position.y + half, raycastLayer);
            v1         = ray.origin; v1.z = 33;
            if (Physics.Raycast(ray, out hit2, dist, swordMask))
            {
                /* v2 = hit2.point; v2.z = 33; Debug.DrawLine(v1, v2, Color.yellow, 5);*/
                raycastsHitSomething = true;
            }



            ray.origin = new Vector3(transform.position.x, transform.position.y - half, raycastLayer);
            v1         = ray.origin; v1.z = 33;
            if (Physics.Raycast(ray, out hit3, dist, swordMask))
            {
                /* v2 = hit3.point; v2.z = 33;Debug.DrawLine(v1, v2, Color.yellow, 5); */
                raycastsHitSomething = true;
            }

            if (raycastsHitSomething)
            {
                float    finalDist     = punchDist;
                Vector3  finalPoint    = Vector3.zero;
                Collider finalCollider = null;
                int      hitChoice     = 0;
                float    dist1         = punchDist;
                float    dist2         = punchDist;
                float    dist3         = punchDist;

                if (hit1.collider != null)
                {
                    dist1 = hit1.distance;
                }
                if (hit2.collider != null)
                {
                    dist2 = hit2.distance;
                }
                if (hit3.collider != null)
                {
                    dist3 = hit3.distance;
                }

                hitChoice = 3;
                if (dist1 <= dist2 && dist1 <= dist3)
                {
                    hitChoice = 1;
                }
                if (dist2 <= dist1 && dist2 <= dist3)
                {
                    hitChoice = 2;
                }
                if (dist3 <= dist1 && dist3 <= dist2)
                {
                    hitChoice = 3;
                }
                //Debug.Log("Hit choice: " + hitChoice + ", D1: " + dist1 + ", D2: " + dist2 + ", D3: " + dist3);
                if (hitChoice == 1)
                {
                    finalDist = hit1.distance; finalPoint = hit1.point; finalCollider = hit1.collider;
                }
                if (hitChoice == 2)
                {
                    finalDist = hit2.distance; finalPoint = hit2.point; finalCollider = hit2.collider;
                }
                if (hitChoice == 3)
                {
                    finalDist = hit3.distance; finalPoint = hit3.point; finalCollider = hit3.collider;
                }



                //	Debug.Log("HIT SOMETHING");
                tempSpeed    = finalDist;
                hitSomething = true;
                transform.SetX(finalPoint.x);

                Info infoScript = null;
                if (hitChoice == 1)
                {
                    infoScript = hit1.collider.GetComponent <Info>();
                }
                if (hitChoice == 2)
                {
                    infoScript = hit2.collider.GetComponent <Info>();
                }
                if (hitChoice == 3)
                {
                    infoScript = hit3.collider.GetComponent <Info>();
                }
                if (infoScript != null)
                {
                    if (infoScript.killPlayer)
                    {
                        hitDeadlyBoxCollider = true;
                    }
                }

                HittableByAirsword hittableScript = finalCollider.gameObject.GetComponent <HittableByAirsword>();
                if (hittableScript != null)
                {
                    hittableScript.HitByPlayer();

                    /*if (hittableScript.giveAirswordBoost)
                     * {
                     *      gotBoost = true;
                     * }*/
                }
            }

            float distCheck = Vector3.Distance(startPos, transform.position);
            if (hitSomething || distCheck > punchDist)
            {
                swordState = SwordState.WrapUp;

                if (distCheck > punchDist)                                //if you moved too far (too little, you probably hit something)
                {
                    if (startPos.x < transform.position.x)
                    {
                        float moveBack = punchDist - distCheck;
                        Debug.Log(moveBack);
                        transform.Translate(new Vector3(moveBack, 0, 0));
                    }
                    else
                    {
                        float moveBack = punchDist - distCheck;
                        Debug.Log(moveBack);
                        transform.Translate(new Vector3(-moveBack, 0, 0));
                    }
                }
                //Debug.Log(Vector3.Distance(startPos,transform.position));
            }
            else
            {
                Vector3 swordVel = new Vector3();
                swordVel.x = (swordDir.x * tempSpeed);
                swordVel.y = (swordDir.y * tempSpeed);

                //transform.SetX(ray.GetPoint(dist).x);

                int split = 15;
                for (int m = split; m > 0; m--)
                {
                    CheckForItems(dist * 1f, transform.position);
                    CheckHurtZones();
                    transform.Translate(swordVel / split);



                    if (Vector3.Distance(startPos, transform.position) > punchDist)
                    {
                        //	Debug.Log(m);
                        //float d = Vector3.Distance(startPos, transform.position) - punchDist;
                        //transform.Translate(new Vector3(-d,0,0));
                        break;
                    }
                }
                //transform.Translate(swordVel);
            }



            if (!NovaPlayerScript.checkPlayerDeathBox(transform.position) && !novaPlayerScript.ThreeDee)
            {
                novaPlayerScript.hpScript.health = 0;
                swordState = SwordState.WrapUp;
            }

            if (novaPlayerScript.hpScript.health <= 0)
            {
                swordState = SwordState.WrapUp;
            }
        }
        break;

        case SwordState.WrapUp:
        {
            Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.RockImpact);
            xa.playerAirSwording               = false;
            swordState                         = SwordState.Setup;
            novaPlayerScript.state             = NovaPlayerScript.State.NovaPlayer;
            novaPlayerScript.DidAirSwordImpact = true;
            novaPlayerScript.vel.y             = 0;

            if (hitDeadlyBoxCollider)
            {
                novaPlayerScript.hpScript.health = 0;
            }

            if (novaPlayerScript.hpScript.health <= 0)
            {
                if (novaPlayerScript.hpScript.setPosWhenKilled)
                {
                    transform.SetX(novaPlayerScript.hpScript.posWhenKilled.x);
                    transform.SetY(novaPlayerScript.hpScript.posWhenKilled.y);
                }
            }

            /*if (gotBoost)
             * {
             *      novaPlayerScript.GotAirswordBoost();
             * }*/

            if (storedJump)
            {
                storedJump = false;
                novaPlayerScript.ExternalPossibleJump();
            }
        }
        break;
        }
    }
Пример #25
0
    public void SwordUpdate()
    {
        if (Controls.GetInputDown(Controls.Type.Jump, novaPlayerScript.playerNumber) && !xa.playerHasJetpack)
        {
            //Debug.Log("PRESSED JUMP WHILE AIRSWORDING");
            storedJump = true;
        }

        switch (swordState)
        {
        case SwordState.Setup:
        {
            hitDeadlyBoxCollider = false;
            swordDir             = Vector3.zero;
            if (xa.playerControlsHeldDir < 0)
            {
                swordDir.x = -1;
            }
            if (xa.playerControlsHeldDir >= 0)
            {
                swordDir.x = 1;
            }
            swordState = SwordState.Charge;

            //play sound effect
            Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.SwordSlice);

            ScreenSlash.ScreenSlashOn(transform.position.y);

            previousTime         = Time.timeScale;
            Time.timeScale       = timeSlowEffect;
            xa.playerAirSwording = true;
            //gotBoost = false;
            novaPlayerScript.Unstick();
        }
        break;

        case SwordState.Charge:
        {
            float dist = swordSpeed * fa.deltaTime;


            //raycast for blocks

            LayerMask  swordMask = 1 << 19 | 1 << 21;                           //Only hits hitboxes on the NovaBlock layer
            Ray        ray       = new Ray();
            RaycastHit hit1      = new RaycastHit();
            RaycastHit hit2      = new RaycastHit();
            RaycastHit hit3      = new RaycastHit();
            ray.direction = swordDir;
            float   tempSpeed            = swordSpeed;
            bool    hitSomething         = false;
            bool    raycastsHitSomething = false;
            float   half = (novaPlayerScript.plHeight * 0.5f);                          // + 0.1f;//ghx
            Vector3 v1   = Vector3.zero;
            Vector3 v2   = Vector3.zero;


            float raycastLayer = xa.GetLayer(xa.layers.RaycastLayer);
            ray.origin = new Vector3(transform.position.x, transform.position.y, raycastLayer);
            v1         = ray.origin; v1.z = 33;
            if (Physics.Raycast(ray, out hit1, dist, swordMask))
            {
                /* v2 = hit1.point; v2.z = 33; Debug.DrawLine(v1, v2, Color.yellow, 5);*/
                raycastsHitSomething = true;
            }


            ray.origin = new Vector3(transform.position.x, transform.position.y + half, raycastLayer);
            v1         = ray.origin; v1.z = 33;
            if (Physics.Raycast(ray, out hit2, dist, swordMask))
            {
                /* v2 = hit2.point; v2.z = 33; Debug.DrawLine(v1, v2, Color.yellow, 5);*/
                raycastsHitSomething = true;
            }



            ray.origin = new Vector3(transform.position.x, transform.position.y - half, raycastLayer);
            v1         = ray.origin; v1.z = 33;
            if (Physics.Raycast(ray, out hit3, dist, swordMask))
            {
                /* v2 = hit3.point; v2.z = 33;Debug.DrawLine(v1, v2, Color.yellow, 5); */
                raycastsHitSomething = true;
            }


            if (raycastsHitSomething)
            {
                float    finalDist     = 9999;
                Vector3  finalPoint    = Vector3.zero;
                Collider finalCollider = null;
                int      hitChoice     = 0;
                float    dist1         = 9999;
                float    dist2         = 9999;
                float    dist3         = 9999;

                if (hit1.collider != null)
                {
                    dist1 = hit1.distance;
                }
                if (hit2.collider != null)
                {
                    dist2 = hit2.distance;
                }
                if (hit3.collider != null)
                {
                    dist3 = hit3.distance;
                }

                hitChoice = 3;
                if (dist1 <= dist2 && dist1 <= dist3)
                {
                    hitChoice = 1;
                }
                if (dist2 <= dist1 && dist2 <= dist3)
                {
                    hitChoice = 2;
                }
                if (dist3 <= dist1 && dist3 <= dist2)
                {
                    hitChoice = 3;
                }
                //Debug.Log("Hit choice: " + hitChoice + ", D1: " + dist1 + ", D2: " + dist2 + ", D3: " + dist3);
                if (hitChoice == 1)
                {
                    finalDist = hit1.distance; finalPoint = hit1.point; finalCollider = hit1.collider;
                }
                if (hitChoice == 2)
                {
                    finalDist = hit2.distance; finalPoint = hit2.point; finalCollider = hit2.collider;
                }
                if (hitChoice == 3)
                {
                    finalDist = hit3.distance; finalPoint = hit3.point; finalCollider = hit3.collider;
                }



                //	Debug.Log("HIT SOMETHING");
                tempSpeed    = finalDist;
                hitSomething = true;
                transform.SetX(finalPoint.x);

                /*
                 * //Debug.Log("AirSwordHitSOmething: " + xa.playerBoxWidth + ", " + xa.playerBoxHeight);
                 * Vector3 a1 = transform.position;
                 * a1.z = 33;
                 * Vector2 a2;
                 *
                 * //draw up
                 * a2 = new Vector3(a1.x, a1.y, a1.z);
                 * a2.y += xa.playerBoxHeight * 0.5f;
                 * //Debug.DrawLine(a1, a2, Color.green, 5);
                 *
                 * //draw down
                 * a2 = new Vector3(a1.x, a1.y, a1.z);
                 * a2.y -= xa.playerBoxHeight * 0.5f;
                 * //Debug.DrawLine(a1, a2, Color.green, 5);
                 *
                 * //draw left
                 * a2 = new Vector3(a1.x, a1.y, a1.z);
                 * a2.x -= xa.playerBoxWidth * 0.5f;
                 * //Debug.DrawLine(a1, a2, Color.green, 5);
                 *
                 * //draw right
                 * a2 = new Vector3(a1.x, a1.y, a1.z);
                 * a2.x += xa.playerBoxWidth * 0.5f;
                 * Debug.DrawLine(a1, a2, Color.green, 5);
                 *
                 *
                 * //draw along the top
                 * a2 = new Vector3(a1.x, a1.y, a1.z);
                 * a2.y += xa.playerBoxHeight * 0.5f;
                 * a2.x -= xa.playerBoxWidth * 0.5f;
                 * Debug.DrawLine(a1, a2, Color.green, 5);
                 *
                 * //draw along the bottom
                 * a2 = new Vector3(a1.x, a1.y, a1.z);
                 * a2.y -= xa.playerBoxHeight * 0.5f;
                 * a2.x -= xa.playerBoxWidth * 0.5f;
                 * Debug.DrawLine(a1, a2, Color.green, 5);
                 *
                 * //draw along the left
                 * a2 = new Vector3(a1.x, a1.y, a1.z);
                 * a2.y += xa.playerBoxHeight * 0.5f;
                 * a2.x += xa.playerBoxWidth * 0.5f;
                 * Debug.DrawLine(a1, a2, Color.green, 5);
                 *
                 * //draw along the right
                 * a2 = new Vector3(a1.x, a1.y, a1.z);
                 * a2.y -= xa.playerBoxHeight * 0.5f;
                 * a2.x += xa.playerBoxWidth * 0.5f;
                 * Debug.DrawLine(a1, a2, Color.green, 5);
                 */
                Info infoScript = null;
                if (hitChoice == 1)
                {
                    infoScript = hit1.collider.GetComponent <Info>();
                }
                if (hitChoice == 2)
                {
                    infoScript = hit2.collider.GetComponent <Info>();
                }
                if (hitChoice == 3)
                {
                    infoScript = hit3.collider.GetComponent <Info>();
                }
                if (infoScript != null)
                {
                    if (infoScript.killPlayer)
                    {
                        hitDeadlyBoxCollider = true;
                    }
                }

                HittableByAirsword hittableScript = finalCollider.gameObject.GetComponent <HittableByAirsword>();
                if (hittableScript != null)
                {
                    hittableScript.HitByPlayer();

                    /*if (hittableScript.giveAirswordBoost)
                     * {
                     *      gotBoost = true;
                     * }*/
                }
            }

            if (hitSomething)
            {
                swordState = SwordState.WrapUp;
            }
            else
            {
                Vector3 swordVel = new Vector3();
                swordVel.x = (swordDir.x * tempSpeed) * fa.deltaTime;
                swordVel.y = (swordDir.y * tempSpeed) * fa.deltaTime;


                int split = 15;
                for (int m = split; m > 0; m--)
                {
                    CheckForItems(dist * 1f, transform.position);
                    CheckHurtZones();
                    transform.Translate(swordVel / split);
                }

                //transform.Translate(swordVel);
            }



            if (!NovaPlayerScript.checkPlayerDeathBox(transform.position) && !novaPlayerScript.ThreeDee)
            {
                novaPlayerScript.hpScript.health = 0;
                swordState = SwordState.WrapUp;
            }

            if (novaPlayerScript.hpScript.health <= 0)
            {
                swordState = SwordState.WrapUp;
            }
        }
        break;

        case SwordState.WrapUp:
        {
            if (novaPlayerScript.altTrailPS_Normal != null)
            {
                novaPlayerScript.altTrailPS_Normal.Play();
                novaPlayerScript.altTrailPS_Airsword.Stop();
            }
            ScreenSlash.ScreenSlashOff();
            Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.RockImpact);
            ScreenShakeCamera.Screenshake(1, 0.25f, ScreenShakeCamera.ScreenshakeMethod.Basic);
            xa.playerAirSwording = false;
            Time.timeScale       = previousTime;                      //1f;
            //Time.timeScale = 0.7f;//previousTime;//1f;
            swordState                         = SwordState.Setup;
            novaPlayerScript.state             = NovaPlayerScript.State.NovaPlayer;
            novaPlayerScript.DidAirSwordImpact = true;
            novaPlayerScript.vel.y             = 0;

            if (hitDeadlyBoxCollider)
            {
                novaPlayerScript.hpScript.health = 0;
            }

            if (novaPlayerScript.hpScript.health <= 0)
            {
                if (novaPlayerScript.hpScript.setPosWhenKilled)
                {
                    transform.SetX(novaPlayerScript.hpScript.posWhenKilled.x);
                    transform.SetY(novaPlayerScript.hpScript.posWhenKilled.y);
                }
            }

            /*if (gotBoost)
             * {
             *      novaPlayerScript.GotAirswordBoost();
             * }*/

            if (storedJump)
            {
                storedJump = false;
                novaPlayerScript.ExternalPossibleJump();
            }
        }
        break;
        }
    }
Пример #26
0
 public void Shoot()
 {
     _nextState = SwordState.Shoot;
 }
Пример #27
0
    private IEnumerator KillCounter()
    {
        yield return(new WaitForSeconds(_aliveTime));

        _nextState = SwordState.Death;
    }
Пример #28
0
 public void AcceptChanges()
 {
     m_ObjectState = SwordState.Current;
 }
Пример #29
0
 public void Hit()
 {
     motionAbsorb.weight = 1.0f;
     swordState = SwordState.Hit;
     swordCollider.enabled = true;
 }
Пример #30
0
    public bool UpdateSword(bool attacking, bool charging)
    {
        tr.Trail(false);

        switch (state)
        {
        case SwordState.idle:
        {
            if (attacking && charging)
            {
                state = SwordState.charging;

                return(true);
            }
            else
            {
                break;
            }
        }

        case SwordState.charging:
        {
            transform.position = Vector3.MoveTowards(transform.position, swordStartTransform.position, chargingStep);
            transform.rotation = Quaternion.RotateTowards(transform.rotation, swordStartTransform.rotation, chargingStep * chargingRotation);

            if (attacking && !charging)
            {
                state = SwordState.attacking;
            }

            return(true);
        }

        case SwordState.attacking:
        {
            transform.position = Vector3.MoveTowards(transform.position, swordEndTransform.position, attackingStep);
            transform.rotation = Quaternion.RotateTowards(transform.rotation, swordEndTransform.rotation, attackingStep * attackingRotation);

            if (transform.position == swordEndTransform.position)
            {
                state = SwordState.resetting;
            }

            tr.Trail(true);

            return(true);
        }

        case SwordState.resetting:
        {
            transform.position = Vector3.MoveTowards(transform.position, swordIdleTransform.position, resettingStep);
            transform.rotation = Quaternion.RotateTowards(transform.rotation, swordIdleTransform.rotation, resettingStep * resettingRotation);

            if (transform.position == swordIdleTransform.position)
            {
                state = SwordState.idle;
            }

            return(true);
        }
        }

        return(false);
    }
Пример #31
0
    //    void Awake()
    //    {
    //        swordCollider = this.GetComponent<CapsuleCollider>();
    //        swordRigidbody = this.GetComponent<Rigidbody>();
    //
    //        if (motionAbsorb == null)
    //        {
    //            motionAbsorb = this.GetComponent<MotionAbsorb>();
    //        }
    //    }
    public void Init(SwordControl swordControl)
    {
        swordCollider = this.GetComponent<BoxCollider>();
        swordRigidbody = this.GetComponent<Rigidbody>();

        motionAbsorb = this.GetComponent<MotionAbsorb>();
        this.swordControl = swordControl;

        motionAbsorb.weight = 0.0f;
        swordState = SwordState.Idle;
        swordCollider.enabled = false;
    }
Пример #32
0
 public void Draw(Vector2 playerPosition, SwordState state)
 {
     World.DrawRotatedOnOrigin(texture, playerPosition + offsets[state], new Vector2(0, 3), GetRotation(state));
 }
Пример #33
0
 public void Idle()
 {
     motionAbsorb.weight = 0.0f;
     swordState = SwordState.Idle;
     swordCollider.enabled = false;
 }
Пример #34
0
 public void ChangeSwordState(SwordState state)
 {
     this.SwordState = state;
 }
Пример #35
0
 public void Swing()
 {
     motionAbsorb.weight = 0.0f;
     swordState = SwordState.Swing;
     swordCollider.enabled = false;
 }
Пример #36
0
 // Use this for initialization
 void Start()
 {
     sword_state = SwordState.Block;
 }