public void InitializeGrapple(Kunai newKunai)
    {
        if (heldRopeSegments == 0)
        {
            kunai.GetComponent <NetworkView>().RPC("SelfDestruct", RPCMode.AllBuffered);
            return;
        }

        kunai                 = newKunai;
        grappleIsOut          = true;
        grappleMassReduced    = false;
        ropeConnectedToPlayer = false;
        lastRopeSegment       = (GameObject)Network.Instantiate(ropePrefab, transform.position, Quaternion.identity, 0);
        lastRopeSegment.GetComponent <RopeDestruction>().kunai = kunai;
        SpringJoint2D   jointSpr = lastRopeSegment.GetComponent <SpringJoint2D>();
        DistanceJoint2D jointDis = lastRopeSegment.GetComponent <DistanceJoint2D>();

        jointSpr.connectedBody = kunai.GetComponent <Rigidbody2D>();
        jointDis.connectedBody = jointSpr.connectedBody;
        Transform ropeBindPoint = kunai.transform.FindChild("RopeBindPoint");

        jointSpr.connectedAnchor = new Vector2(ropeBindPoint.localPosition.x, ropeBindPoint.localPosition.y);
        jointDis.connectedAnchor = jointSpr.connectedAnchor;
        ropeSegSize       = lastRopeSegment.GetComponent <SpriteRenderer>().sprite.bounds.size.x;
        jointSpr.distance = ropeSegSize;
        jointDis.distance = ropeSegSize;
    }
Esempio n. 2
0
 void Start()
 {
     kunaiScript = GetComponent <Kunai>();
     agent       = GetComponent <NavMeshAgent>();
     turret1     = GameObject.FindGameObjectWithTag("ET");
     targetBase  = GameObject.FindGameObjectWithTag("EnemyBase");
     InvokeRepeating("UpdateTarget", 0f, 0.1f);
 }
Esempio n. 3
0
    void Start()
    {
        agent     = GetComponent <NavMeshAgent>();
        target    = GameObject.FindGameObjectWithTag("Player");
        turret1   = GameObject.FindGameObjectWithTag("Player");
        enemyBase = GameObject.FindGameObjectWithTag("EnemyBase");

        kunaiScript = GetComponent <Kunai>();

        state = State.turretScouting;
    }
Esempio n. 4
0
    void Start()
    {
        agent      = GetComponent <NavMeshAgent>();
        turret1    = GameObject.FindGameObjectWithTag("PT");
        playerBase = GameObject.FindGameObjectWithTag("PlayerBase");

        kunaiScript = GetComponent <Kunai>();

        InvokeRepeating("UpdateTarget", 1f, 1f);

        state = State.turretScouting;
    }
Esempio n. 5
0
 public Kisame()
 {
     Name    = "Kisame";
     Level   = 1;
     Hp      = 25;
     Exp     = 50;
     Gold    = Utility.RollDice(100 * Level);
     Armor   = new FlakJacket();
     Defence = Armor.Defence;
     Weapon  = new Kunai();
     Damage  = Weapon.Damage;
 }
Esempio n. 6
0
    // 特技;射撃
    public override void Specialty()
    {
        GameObject obj   = (GameObject)Instantiate(bullet, transform.position, Quaternion.identity);
        Kunai      kunai = obj.GetComponent <Kunai>();

        Debug.Log(kunai.transform.rotation);
        kunai.SetBullet(transform.position, aim.transform.localEulerAngles, GetPower());
        // 吹っ飛び
        if (!GetComponent <PlayerController> ().isGround)
        {
            Vector3 aimVec   = aim.transform.localEulerAngles;
            float   h        = -1 * Mathf.Cos(Mathf.Deg2Rad * aimVec.z) * Mathf.Max(15.0f - decDash, 0);
            float   v        = -1 * Mathf.Sin(Mathf.Deg2Rad * aimVec.z) * Mathf.Max(20.0f - decDash, 0);
            Vector2 kunaiVec = new Vector2(h, v);
            GetComponent <Rigidbody2D> ().AddForce(kunaiVec, ForceMode2D.Impulse);
            decDash += deltaDash;
        }
    }
    void disparar(Vector3 _firePoint)
    {
        if (Kunai != null && _firePoint != null && this.gameObject != null)
        {
            GameObject myKunai = Instantiate(Kunai, _firePoint, Quaternion.identity) as GameObject;

            Kunai          kunaiComponent = myKunai.GetComponent <Kunai>();
            SpriteRenderer kunaiSr        = myKunai.GetComponent <SpriteRenderer>();
            if (spriteNinja.flipX == true)
            {
                kunaiSr.flipX            = true;
                kunaiComponent.direccion = Vector2.left;
            }
            if (spriteNinja.flipX == false)
            {
                kunaiSr.flipX            = false;
                kunaiComponent.direccion = Vector2.right;
            }
        }
    }
Esempio n. 8
0
    private void Attacking()//~
    {
        // Get the pool of Kunais
        GameObject kunai = KunaiPooler.sharedInstance.GetPooledKunais();

        if (kunai != null)
        {
            // Obtain the scripting of the Kunai to perform in-script tactics
            Kunai kunaiScript = kunai.GetComponent <Kunai
                                                    >();
            // Set the direction flipper to the kunai.
            kunaiScript.directionFlip = directionFlipper;
            // Set the euler angles of the kunai to match with the player
            kunai.transform.eulerAngles = transform.eulerAngles;
            // Setting the Enumerate of Turning and Gravity of the Kunai
            //  on the dependence of the direction and gravity movement
            if (direction == Direction.Right && moveOnX)
            {
                kunaiScript.turningAndGravity = Kunai.TurningAndGravity.isRightMoveX;
            }
            else if (direction == Direction.Right && !moveOnX)
            {
                kunaiScript.turningAndGravity = Kunai.TurningAndGravity.isRightMoveY;
            }
            else if (direction == Direction.Left && moveOnX)
            {
                kunaiScript.turningAndGravity = Kunai.TurningAndGravity.isLeftMoveX;
            }
            else if (direction == Direction.Left && !moveOnX)
            {
                kunaiScript.turningAndGravity = Kunai.TurningAndGravity.isLeftMoveY;
            }
            // Bring the kunai from its current position to the player's position
            kunai.transform.position = attackLocation.position;
            // Activate kunai.
            kunai.SetActive(true);
        }
    }
Esempio n. 9
0
    void Start()
    {
        kunaiScript = GetComponent <Kunai>();

        InvokeRepeating("UpdateTarget", 0f, 0.1f);
    }
 void Start()
 {
     kunai = GetComponentInParent <Kunai>();
     id    = GetComponentInParent <ID>();
     audio = GetComponentInParent <ThrowingAudio>();
 }
Esempio n. 11
0
 void Start()
 {
     controller  = GetComponent <PlayerController>();
     kunaiScript = GetComponent <Kunai>();
     viewCamera  = Camera.main;
 }
Esempio n. 12
0
        private void HandleJumpInput()
        {
            var directionalInputX = 0;

            var keyLeft  = InputHandler.Instance.IsPressed(0, Buttons.LeftThumbstickLeft, Keys.Left);
            var keyRight = InputHandler.Instance.IsPressed(0, Buttons.LeftThumbstickRight, Keys.Right);

            if (keyLeft)
            {
                directionalInputX = -1;
            }
            if (keyRight)
            {
                directionalInputX = 1;
            }

            var isKeyJumpPressed = InputHandler.Instance.IsPressed(0, Buttons.A, Keys.Space);
            var isKeyJumpUp      = !InputHandler.Instance.IsPressed(0, Buttons.A, Keys.Space);
            var isBKey           = InputHandler.Instance.WasPressed(0, Buttons.B, Keys.LeftControl);
            var isXKey           = InputHandler.Instance.WasPressed(0, Buttons.X, Keys.LeftShift);

            if (isKeyJumpPressed)
            {
                if (CurrentState == CharState.Jumping)
                {
                    CurrentState = CharState.Glide;
                }

                CurrentState = CharState.Jumping;
                if (wallSliding)
                {
                    if (wallDirX == -1 && keyLeft || wallDirX == 1 && keyRight)
                    {
                        velocity.X = -wallDirX * wallJumpClimb.X;
                        velocity.Y = wallJumpClimb.Y;
                    }
                    else if (!keyLeft && !keyRight)
                    {
                        velocity.X = -wallDirX * wallJumpOff.X;
                        velocity.Y = wallJumpOff.Y;
                    }
                    else
                    {
                        velocity.X = -wallDirX * wallLeap.X;
                        velocity.Y = wallLeap.Y;
                    }
                }
                if (controller.collisions.below)
                {
                    if (controller.collisions.slidingDown)
                    {
                        if (directionalInputX != -Math.Sign(controller.collisions.slopeNormal.X))
                        {
                            velocity.Y = maxJumpVelocity * controller.collisions.slopeNormal.Y;
                            velocity.X = maxJumpVelocity * controller.collisions.slopeNormal.X;
                        }
                    }
                    else
                    {
                        velocity.Y = -maxJumpVelocity;
                    }
                }
            }
            if (isKeyJumpUp)
            {
                if (velocity.Y < -minJumpVelocity)
                {
                    velocity.Y = -minJumpVelocity;
                }
            }

            if (isBKey)
            {
                CurrentState = CharState.GroundThrow;
                var location = new Vector2(Transform.Position.X, Transform.Position.Y); /*+ (trajectoryY * 50)); // Adding something since the kunai spawns before the animation*/
                var kunai    = new Kunai(location, controller.collisions.faceDirection, context);
                kunai.LoadContent(context.content);
                context.lvl.AddSprite(Guid.NewGuid().ToString(), kunai);
                kunai.Initialize();
            }

            if (isXKey)
            {
                CurrentState = CharState.GroundAttack;
            }
        }
    void FixedUpdate()
    {
        // Grounded Setup
        grounded = Physics2D.OverlapCircle(groundCheck.position, groundRadius, whatIsGround);
        // Falling Setup + Jumping Setup Part 1
        if (!grounded && !Input.GetButton("Jump"))
        {
            rb.velocity = new Vector2(rb.velocity.x, rb.velocity.y - 0.5f);
        }

        // Movement Setup
        horizontalMove = Input.GetAxis("Horizontal");
        //	Multi-Tap System
        if (Input.GetButtonDown("Horizontal"))
        {
            if (horizontalTapCooler > 0f && horizontalTapCount == 2)
            {
                // Double Tap Running
                //isRunning = true;
            }
            else
            {
                horizontalTapCooler = 0.5f;
                horizontalTapCount++;
            }
        }
        if (horizontalTapCooler > 0f)
        {
            horizontalTapCooler -= 0.5f * Time.deltaTime;
            if (horizontalTapCooler < 0f)
            {
                horizontalTapCooler = 0f;
            }
        }
        else
        {
            horizontalTapCount = 0;
        }
        // The Effects of the Movement Setup as well as the Multi-Tap System
        if (!isGravity)
        {
            if (!isRunning)
            {
                rb.velocity = new Vector2(horizontalMove * movementSpeed, rb.velocity.y);
            }
            else if (isRunning && horizontalMove != 0)
            {
                rb.velocity = new Vector2((horizontalMove * 4) * movementSpeed, rb.velocity.y);
            }
            else if (isRunning && horizontalMove == 0)
            {
                isRunning = false;
            }
        }
        // Character Rotation
        if (horizontalMove < 0 && transform.rotation.y != 180)
        {
            transform.eulerAngles = new Vector2(0, 180);
        }
        else if (horizontalMove > 0 && transform.rotation.y != 0)
        {
            transform.eulerAngles = new Vector2(0, 0);
        }

        isEnemyClose = enemyTracker.GetComponent <EntityEncounter>().isEnemyClose;
        // Attacking Setup
        if (Input.GetButtonDown("Attack"))
        {
            // KUNAI Weapon Setup
            if (!isEnemyClose)
            {
                isAttacking = true;
                GameObject weaponA = KunaiPooler.sharedInstance.GetPooledKunais();
                if (weaponA != null)
                {
                    Kunai weaponAScript = weaponA.GetComponent <Kunai>();
                    weaponAScript.isRight      = (transform.eulerAngles.y == 0);
                    weaponA.transform.position = attackLocation.transform.position;
                    weaponA.SetActive(true);
                }
            }
            else
            {
                isCloseAttacking = true;
                CreateCloseAttackCollider();
            }
        }

        // Gravity Setup Part 1
        isGravity = Input.GetButton("Gravity");
        if (isGravity)
        {
            // Freeze the character in place; both X and Y axis
            rb.constraints = RigidbodyConstraints2D.FreezePosition;
            // If Player moves left or right
            if (Input.GetButtonDown("Horizontal") && horizontalMove > 0)
            {
                stage.transform.eulerAngles = new Vector3(0, 0, stage.transform.eulerAngles.z + 90);
            }
            else if (Input.GetButtonDown("Horizontal") && horizontalMove < 0)
            {
                stage.transform.eulerAngles = new Vector3(0, 0, stage.transform.eulerAngles.z - 90);
            }
        }
        else
        {
            rb.constraints = RigidbodyConstraints2D.FreezeRotation;
        }
    }