Exemplo n.º 1
0
    public void Leap()
    {
        if (((Target.tag == "Floor") && (storedTarget.tag == "Cieling")) || ((Target.tag == "Cieling") && (storedTarget.tag == "Floor")) || ((Target.tag == "Left") && (storedTarget.tag == "Right")) || ((Target.tag == "Right") && (storedTarget.tag == "Left")))
        {
            faceRight = !faceRight;
        }

        if (LeapTarget != null && storedTarget != Target)
        {
            Target = storedTarget;

            //grounded = false;
            //leaping = true;
            transform.position = LeapTarget;
            if (Target.tag == "Floor" || Target.tag == "Cieling")
            {
                Shaker.GetComponent <shake>().Shaking("top");
            }
            if (Target.tag == "Right" || Target.tag == "Left")
            {
                Shaker.GetComponent <shake>().Shaking("side");
            }
        }

        if (LeapTarget != null && storedTarget == Target)
        {
            storedTarget       = Target;
            transform.position = LeapTarget;
        }
    }
Exemplo n.º 2
0
 // Start is called before the first frame update
 void Start()
 {
     rb = GetComponent <Rigidbody2D>();
     rb.gravityScale = 0;
     myTransform     = transform;
     attractor       = GameObject.FindGameObjectWithTag("Floor").GetComponent <GravAttractor>();
 }
Exemplo n.º 3
0
    public void Launch(Vector2 dir)
    {
        slam     = true;
        canInput = false;
        canMove  = false;
        RaycastHit2D hitInfo = Physics2D.Raycast(transform.position, dir, 10000, floor);

        if (hitInfo)
        {
            GravAttractor wall = hitInfo.transform.GetComponent <GravAttractor>();
            storedTarget = wall;;
            if (((Target.tag == "Floor") && (storedTarget.tag == "Cieling")) || ((Target.tag == "Cieling") && (storedTarget.tag == "Floor")) || ((Target.tag == "Left") && (storedTarget.tag == "Right")) || ((Target.tag == "Right") && (storedTarget.tag == "Left")))
            {
                faceRight = !faceRight;
            }
            Target = storedTarget;
            Vector2 launchTarget = hitInfo.point;
            transform.position = launchTarget;
            if (Target.tag == "Floor" || Target.tag == "Cieling")
            {
                Shaker.GetComponent <shake>().Shaking("top");
            }
            if (Target.tag == "Right" || Target.tag == "Left")
            {
                Shaker.GetComponent <shake>().Shaking("side");
            }
            gripLoss = 1f;
        }
    }
Exemplo n.º 4
0
 // Use this for initialization
 void Awake()
 {
     rb             = GetComponent <Rigidbody>();
     grav           = GameObject.FindGameObjectWithTag("Planet").GetComponent <GravAttractor> ();
     rb.useGravity  = false;
     rb.constraints = RigidbodyConstraints.FreezeRotation;
 }
Exemplo n.º 5
0
    public Vector2 AimLeap()
    {
        if (LeapAim.localPosition.y != .75f)
        {
            LeapAim.localPosition = new Vector3(0, .75f, 0);
        }
        if (!cancelled)
        {
            canMove = false;
            lineRenderer.enabled = true;
            RaycastHit2D hitInfo = Physics2D.Raycast(new Vector3(LeapAim.position.x, LeapAim.localPosition.y + aimExtend, LeapAim.position.z), LeapAim.up);
            if (hitInfo)
            {
                GameObject attck = hitInfo.transform.gameObject;

                GravAttractor wall = hitInfo.transform.GetComponent <GravAttractor>();
                GravBody      foe  = hitInfo.transform.GetComponent <GravBody>();
                if (wall != null)
                {
                    lineRenderer.SetPosition(0, LeapAim.position);
                    lineRenderer.SetPosition(1, hitInfo.point);
                    storedTarget = wall;
                }
                if ((foe != null) && (foe != this.GetComponent <GravBody>()))
                {
                    lineRenderer.SetPosition(0, LeapAim.position);
                    lineRenderer.SetPosition(1, hitInfo.point);
                    storedTarget = foe.GetComponent <GravBody>().attractor;
                }
                if (attck != null)
                {
                    PlayerControl Oattack = attck.GetComponent <PlayerControl>();
                    Projectile    ammo    = attck.GetComponent <Projectile>();
                    if ((Oattack != null && Oattack.attack != null) || ammo != null)
                    {
                        storedTarget = Target;
                        lineRenderer.SetPosition(0, LeapAim.position);
                        lineRenderer.SetPosition(1, hitInfo.point);
                    }
                }
                if (wall == null && foe == null)
                {
                    storedTarget = Target;
                    lineRenderer.SetPosition(0, LeapAim.position);
                    lineRenderer.SetPosition(1, LeapAim.position + LeapAim.up * 1000);
                }
                LeapTarget = hitInfo.point;

                LeapAim.localEulerAngles = new Vector3(LeapAim.localRotation.x, LeapAim.localRotation.y, -aim);
            }
            return(LeapTarget);
        }
        else
        {
            storedTarget = Target;
            return(transform.position);
        }
    }
Exemplo n.º 6
0
 // Update is called once per frame
 void FixedUpdate()
 {
     shrinkTimer -= Time.deltaTime;
     if (shrinkTimer < 0)
     {
         if (barImage.fillAmount < damageBar.fillAmount)
         {
             damageBar.fillAmount -= shrinkSpeed * Time.deltaTime;
         }
     }
     hitPoints = playerSelected.HP - playerSelected.damage;
     if (hitPoints < 0)
     {
         defeated = true;
     }
     attackCharge = playerSelected.attackCharge;
     targetTag    = playerSelected.Target;
     faceRight    = playerSelected.faceRight;
 }
Exemplo n.º 7
0
    protected void Awake()
    {
        anim         = GetComponent <Animator>();
        Shaker       = GameObject.FindGameObjectWithTag("Shake");
        maxGrip      = fighter.weight;
        HP           = fighter.HitPoints;
        jumpHeight   = fighter.jumpHeight;
        moveSpeed    = fighter.speed;
        maxJumpCount = fighter.jumpCount;
        rigidBody    = GetComponent <Rigidbody2D>();
        Target       = GameObject.FindGameObjectWithTag("Floor").GetComponent <GravAttractor>();
        Shield       = GetComponentInChildren <Barrier>(true).gameObject;
        if (isPlayer)
        {
            player = ReInput.players.GetPlayer(playerID); //The player controlling this fighter
        }
        gameObject.name = fighter.name.ToString() + playerID;
        statemachine    = new StateMachine();
        var flinch       = new Flinch(this);
        var walk         = new Walk(this);
        var run          = new Run(this);
        var idle         = new Idle(this);
        var jump         = new Jump(this);
        var groundattack = new GroundAttack(this, attack);
        var airattack    = new AirAttack(this, attack);
        var stun         = new Stun(this);
        var leapprep     = new LeapPrep(this);
        var blocking     = new Blocking(this);
        var dodge        = new AirDodge(this);
        var leap         = new Leaping(this);
        var prone        = new Prone(this);

        At(dodge, idle, landed());
        At(flinch, idle, stunless());
        At(run, idle, stop());
        At(walk, idle, stop());
        At(idle, jump, jumping());
        At(idle, jump, unground());
        At(jump, jump, jumping());
        At(walk, jump, unground());
        At(run, jump, unground());
        At(walk, jump, jumping());
        At(run, jump, jumping());
        At(walk, run, running());
        At(run, walk, walking());
        At(idle, walk, walking());
        At(idle, run, running());
        At(idle, groundattack, offensive());
        At(walk, groundattack, offensive());
        At(run, groundattack, offensive());
        At(jump, airattack, offensive());
        At(groundattack, idle, unoffensive());
        At(airattack, jump, unoffensive());
        At(airattack, idle, landed());
        At(jump, airattack, offensive());
        At(jump, idle, landed());
        At(jump, dodge, guard());
        At(blocking, stun, pierce());
        At(idle, blocking, guard());
        At(walk, blocking, guard());
        At(run, blocking, guard());
        At(leapprep, idle, cancelleap());
        At(leapprep, leap, gravityChange());
        At(blocking, idle, unguard());
        At(leap, idle, landed());
        At(prone, idle, stunless());
        statemachine.AddAnyTransition(leapprep, () => LeapPrep && leapCooldown <= 0);
        statemachine.AddAnyTransition(stun, () => stunned);
        statemachine.AddAnyTransition(flinch, () => isDamaged);
        statemachine.AddAnyTransition(prone, () => slam);
        Func <bool> stunless() => () => doneStun == true;
        Func <bool> walking() => () => speed > 0.3 && speed < 0.7;
        Func <bool> running() => () => speed > 0.7;
        Func <bool> stop() => () => speed < 0.3;
        Func <bool> jumping() => () => (jumpTimer > Time.time) && (maxJumpCount > jumpCount) && !action && actionCooldown > 0;
        Func <bool> offensive() => () => attack != null && actionCooldown > 0;
        Func <bool> unoffensive() => () => attack == null;
        Func <bool> landed() => () => grounded;
        Func <bool> pierce() => () => Guard <= 0;
        Func <bool> guard() => () => isBlocking && actionCooldown > 0;
        Func <bool> unguard() => () => !isBlocking;
        Func <bool> gravityChange() => () => LeapRelease;
        Func <bool> cancelleap() => () => cancelled;
        Func <bool> unground() => () => !grounded;

        statemachine.SetState(idle);
    }