Example #1
0
 public override void Ability(CharacterScript target)
 {
     if (mana >= manaCost)
     {
         // target.TakeDmg(abilityDmg);
         ReduceMana(manaCost);
         FireBallScript fireAttack = Instantiate(fireBall).GetComponent <FireBallScript>();
         fireAttack.gameObject.transform.position = transform.position;
         fireAttack.FireAttack(target, abilityDmg);
     }
 }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        if (shoot == true)
        {
            if (time < Time.time)
            {
                FireBallScript BallFire = Instantiate(BallFirePrefab, transform.position, transform.rotation) as FireBallScript;
                BallFire.fireDir = fireDir2;

                time = Time.time + fireBallDelay;
            }
        }
    }
Example #3
0
    void OnTriggerEnter2D(Collider2D coll)
    {
        if (coll.gameObject.tag == "FireBall")
        {
            FireBallScript fire = coll.gameObject.GetComponent <FireBallScript>();
            Generator.Spawn(fire.particle, fire.gameObject.transform.position, Quaternion.identity);
            Destroy(coll.gameObject);

            this.vida -= 1;
            if (vida <= 0)
            {
                Generator.Data.enemiesKilled++;
                Destroy(this.gameObject);
            }
        }
    }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        if (MP >= FIRE_BALL_MP)
        {
            if (Input.GetKeyDown(KeyCode.X))
            {
                MP -= FIRE_BALL_MP;
                GameObject fireBall = GameObject.Instantiate(FireBall) as GameObject;

                fireBall.transform.position = this.transform.position;

                FireBallScript script = fireBall.GetComponent <FireBallScript> ();

                script.Velicity = this.transform.forward * 20;
            }
        }
    }
    void OnTriggerEnter2D(Collider2D other)
    {
        if ((other.CompareTag("Player1") && this.CompareTag("Fireball2")) || (other.CompareTag("Player2") && this.CompareTag("Fireball1")))
        {
            rb2D.velocity = Vector3.zero;

            if (other.CompareTag("Player1"))
            {
                GameObject     player1 = GameObject.Find("Player1");
                FireBallScript script  = player1.GetComponent <FireBallScript> ();
                if (script.firingBall)
                {
                    script.reset_scale();
                }
            }

            if (other.CompareTag("Player2"))
            {
                GameObject      player2 = GameObject.Find("Player2");
                FireBallScript1 script  = player2.GetComponent <FireBallScript1> ();
                if (script.firingBall)
                {
                    script.reset_scale();
                }
            }

            GameObject eball = Instantiate(EnergyBubble, transform.position, transform.rotation) as GameObject;
            eball.transform.localScale = new Vector3(0.08f * transform.localScale.x, 0.08f * transform.localScale.y);
            Rigidbody2D rig = other.gameObject.GetComponent <Rigidbody2D> ();

            Vector2 force = new Vector2(-this.transform.position.x + other.transform.position.x, -this.transform.position.y + other.transform.position.y);
            rig.AddForce(force * 5000f * transform.localScale.x);

            Destroy(gameObject, 0);
        }

        if (other.CompareTag("Obstacle"))
        {
            rb2D.velocity = Vector3.zero;
            GameObject eball = Instantiate(EnergyBubble, transform.position, transform.rotation) as GameObject;
            eball.transform.localScale = new Vector3(0.08f * transform.localScale.x, 0.08f * transform.localScale.y);
            Destroy(gameObject, 0);
        }
    }
    public IEnumerator AlligatoerAttack(DefaultAttackData _defaultData, ExtraAttackData _extraData)
    {
        yield return(StartCoroutine(SwingWeapon(_defaultData.m_fAttackSpeed, _defaultData.m_fWeaponAxisStart, _defaultData.m_fWeaponAxisEnd, _defaultData.rightFunctionPointer(), _defaultData.hitList)));

        if (_defaultData.hitList.Count > 0)
        {
            //0 이상이면 무기에 맞는놈이있다.
            //Hit and 넉벡
            Debug.Log("HIT");
        }
        else
        {
            //Only For Test
            //무기에 맞는놈이 없으므로 파이어볼
            GameObject firballObject = MonoBehaviour.Instantiate(alligatorFireBallPrefab) as GameObject;
            firballObject.transform.position = new Vector3(parentsObject.transform.position.x +
                                                           (_defaultData.rightFunctionPointer() == true ? +0.2f : -0.2f),
                                                           parentsObject.transform.position.y,
                                                           parentsObject.transform.position.z);
            AlligatorAttackModel argModel = new AlligatorAttackModel();

            argModel.bulletSpeed      = 0.06f; // 0.1 x move
            argModel.destroySprite    = alligatorEndObject;
            argModel.frame            = 10.0f; // ms
            argModel.endFrameMultiple = 3;     // ms
            argModel.isRight          = _defaultData.rightFunctionPointer();
            argModel.scale            = 1.0f;  // multiple Scale
            argModel.sheetingArea     = 5.0f;
            argModel.sheetingSprite   = alligatorSheetingObject;
            argModel.targetArray      = new ArrayList();
            argModel.targetArray.Add(GlobalLayerMask.ENEMY_MASK);

            FireBallScript firballScript = firballObject.GetComponent <FireBallScript>();

            firballScript.SetParameter(argModel);
        }
    }
Example #7
0
    void shootFire()
    {
        magic = FireBall.GetComponent <FireBallScript>();
        string temp = magic.changeDirection(direction);

        switch (temp)
        {
        case "forward":
            GameObject.Instantiate(FireBall, this.transform.position + new Vector3(0f, .2f, 0f), magic.rotation());
            break;

        case "back":
            GameObject.Instantiate(FireBall, this.transform.position + new Vector3(0f, -.2f, 0f), magic.rotation());
            break;

        case "right":
            GameObject.Instantiate(FireBall, this.transform.position + new Vector3(0.2f, 0f, 0f), magic.rotation());
            break;

        case "left":
            GameObject.Instantiate(FireBall, this.transform.position + new Vector3(-.2f, 0f, 0f), magic.rotation());
            break;
        }
    }
Example #8
0
    //legge gli imput e muove il player
    private void Controll()
    {
        if (name == "Mario")
        {
            //mettere in pausa il gioco
            if (Input.GetKeyUp(KeyCode.Escape))
            {
                gameManger.Pause();
            }
            //Salto Mario
            if (Input.GetKeyDown(KeyCode.Space) && !isJump)
            {
                doubleJump++;
                Jump();
                DoubleJump();
            }
            //Movimento sinistra mario
            else if (Input.GetKey(KeyCode.A))
            {
                tr.position += new Vector3(movementSpeed * Time.deltaTime, 0, 0);
                isRight      = false;
            }
            //Movimento destra mario
            else if (Input.GetKey(KeyCode.D))
            {
                tr.position += new Vector3(-movementSpeed * Time.deltaTime, 0, 0);
                isRight      = true;
            }

            if (Input.GetKeyDown(KeyCode.F) && status == PlayerStatus.flower)
            {
                if (isRight)
                {
                    FireBallScript ball = Instantiate(fireball, tr.position + new Vector3(-1, 0, 0), Quaternion.identity).GetComponent <FireBallScript>();
                    ball.Shoot(isRight);
                }
                else
                {
                    FireBallScript ball = Instantiate(fireball, tr.position + new Vector3(1, 0, 0), Quaternion.identity).GetComponent <FireBallScript>();
                    ball.Shoot(isRight);
                }
            }
        }
        else if (name == "Luigi")
        {
            //salto Luigi
            if (Input.GetKeyDown(KeyCode.UpArrow) && !isJump)
            {
                doubleJump++;
                Jump();
                DoubleJump();
            }
            //Movimento sinistra luigi
            else if (Input.GetKey(KeyCode.LeftArrow))
            {
                tr.position += new Vector3(movementSpeed * Time.deltaTime, 0, 0);
            }
            //Movimento destra luigi
            else if (Input.GetKey(KeyCode.RightArrow))
            {
                tr.position += new Vector3(-movementSpeed * Time.deltaTime, 0, 0);
            }
        }
    }
Example #9
0
    void FixedUpdate()
    {
        updateUI();
        if (HP <= 0)
        {
            Dying();
            return;
        }

        if (pushBack > 0)
        {
            pushBack--;
            transform.position += pushVec * pushSpeed * Time.deltaTime;
        }



        float h = Input.GetAxis("Horizontal");                                  // setup h variable as our horizontal input axis
        float v = Input.GetAxis("Vertical");                                    // setup v variables as our vertical input axis

        if (v == 0 && h != 0)
        {
            v = 0.2f;
        }

        anim.SetFloat("Speed", v * moveSpeed);                                          // set our animator's float parameter 'Speed' equal to the vertical input axis
        anim.SetFloat("Direction", h);                                                  // set our animator's float parameter 'Direction' equal to the horizontal input axis
        anim.speed = animSpeed;                                                         // set the speed of our animator to the public variable 'animSpeed'



        currentBaseState = anim.GetCurrentAnimatorStateInfo(0);         // set our currentState variable to the current state of the Base Layer (0) of animation

        if (anim.layerCount == 2)
        {
            layer2CurrentState = anim.GetCurrentAnimatorStateInfo(1);                   // set our layer2CurrentState variable to the current state of the second Layer (1) of animation
        }
        bool attackPressed = Input.GetMouseButtonDown(0);

        if (attackPressed && MP > 20)
        {
            MP -= 20;

            anim.SetBool("Attack", true);
            shoot = true;
        }

        if (currentBaseState.nameHash == attackState)
        {
            if (!anim.IsInTransition(0))
            {
                // reset the Jump bool so we can jump again, and so that the state does not loop

                if (shoot)
                {
                    GameObject fireBall = GameObject.Instantiate(Resources.Load("FireBall")) as GameObject;
                    shoot = false;
                    fireBall.transform.position = rightHand.transform.position;
                    fireBall.transform.rotation = Quaternion.Euler(new Vector3(0, transform.rotation.eulerAngles.y + 180, 0));
                    FireBallScript fireBallScript = fireBall.GetComponent <FireBallScript>();


                    Vector3 shootV = transform.forward;
                    fireBallScript.Velicity = shootV * 8;
                }



                anim.SetBool("Attack", false);
            }
        }

        // STANDARD JUMPING

        // if we are currently in a state called Locomotion, then allow Jump input (Space) to set the Jump bool parameter in the Animator to true
        if (currentBaseState.nameHash == locoState)
        {
            if (Input.GetButtonDown("Jump"))
            {
                anim.SetBool("Jump", true);
                rigidbody.AddForce(Vector3.up * 200);

                rigidbody.velocity = new Vector3(0, 100, 0);
            }
        }



        // if we are in the jumping state...
        else if (currentBaseState.nameHash == jumpState)
        {
            //  ..and not still in transition..
            if (!anim.IsInTransition(0))
            {
                // reset the Jump bool so we can jump again, and so that the state does not loop
                anim.SetBool("Jump", false);
            }

            // Raycast down from the center of the character..
            Ray        ray     = new Ray(transform.position + Vector3.up, -Vector3.up);
            RaycastHit hitInfo = new RaycastHit();

            if (Physics.Raycast(ray, out hitInfo))
            {
                // ..if distance to the ground is more than 1.75, use Match Target
                if (hitInfo.distance > 1.75f)
                {
                    // MatchTarget allows us to take over animation and smoothly transition our character towards a location - the hit point from the ray.
                    // Here we're telling the Root of the character to only be influenced on the Y axis (MatchTargetWeightMask) and only occur between 0.35 and 0.5
                    // of the timeline of our animation clip
                    anim.MatchTarget(hitInfo.point, Quaternion.identity, AvatarTarget.Root, new MatchTargetWeightMask(new Vector3(0, 1, 0), 0), 0.35f, 0.5f);
                }
            }
        }


        // JUMP DOWN AND ROLL

        // if we are jumping down, set our Collider's Y position to the float curve from the animation clip -
        // this is a slight lowering so that the collider hits the floor as the character extends his legs
        else if (currentBaseState.nameHash == jumpDownState)
        {
            col.center = new Vector3(0, anim.GetFloat("ColliderY"), 0);
        }

        // if we are falling, set our Grounded boolean to true when our character's root
        // position is less that 0.6, this allows us to transition from fall into roll and run
        // we then set the Collider's Height equal to the float curve from the animation clip
        else if (currentBaseState.nameHash == fallState)
        {
            col.height = anim.GetFloat("ColliderHeight");
        }

        // if we are in the roll state and not in transition, set Collider Height to the float curve from the animation clip
        // this ensures we are in a short spherical capsule height during the roll, so we can smash through the lower
        // boxes, and then extends the collider as we come out of the roll
        // we also moderate the Y position of the collider using another of these curves on line 128
        else if (currentBaseState.nameHash == rollState)
        {
            if (!anim.IsInTransition(0))
            {
                col.center = new Vector3(0, anim.GetFloat("ColliderY"), 0);
            }
        }


        if (HP > 0)
        {
            if (currentBaseState.nameHash == hurtState)
            {
                if (!anim.IsInTransition(0))
                {
                    anim.SetBool("Hurt", false);
                }
            }
        }
    }