コード例 #1
0
 protected override void Attack()
 {
     if (changePhase)
     {
         if (state == States.Idle)
         {
             //Carrega Laser
             state = States.Move;
             animator.ChangeState(state, direction);
         }
         else if (state == States.Move)
         {
             //Dispara Laser
             state = States.Attack;
             animator.ChangeState(state, direction);
             laserFiring = true;
             StopCoroutine("ShootLaser");
             StartCoroutine("ShootLaser");
         }
         else if (state == States.Attack)
         {
             state = States.Idle;
             animator.ChangeState(state, direction);
             laserFiring = false;
         }
         changePhase = false;
         StartCoroutine(SequenceTimer());
     }
 }
コード例 #2
0
    protected override void Shoot()
    {
        Vector3 shootVec = PlayerController.Instance.transform.position - transform.position;

        FireProjectile(BasicProjectile.Owner.Enemy, shootVec);

        animator.ChangeState(States.Attack, direction);
    }
コード例 #3
0
    protected override void Shoot()
    {
        animator.ChangeState(States.Idle, direction);          //Idle animation is same as attack animation
        Vector3 shootVec = PlayerController.Instance.transform.position - transform.position;

        for (int i = 0; i < NumOfProjectiles; i++)
        {
            FireProjectile(BasicProjectile.Owner.Enemy, Quaternion.Euler(0, i * spread, 0) * shootVec);
        }
    }
コード例 #4
0
 protected override void Shoot()
 {
     if (PlayerController.Instance != null && EnemyController.Instance.GetEnemies().Count > 0)
     {
         Vector3 shootVec = NearestEnemyPos() - transform.position;
         CalculateDirection(shootVec);
         FireProjectile(BasicProjectile.Owner.Player, shootVec);
         state = States.Attack;
         animator.ChangeState(state, direction);
         attacking = true;
     }
 }
コード例 #5
0
    protected override void Move()
    {
        if (PlayerController.Instance != null)
        {
            Vector3 dir;
            if (changeVelocity)
            {
                dir = (PlayerController.Instance.transform.position - transform.position).normalized;

                if (state == States.Attack)
                {
                    //corre atras do Jogador
                    moveVelocity = dir * movespeed * Time.deltaTime * dashSpeedMultiplier;
                }
                else
                {
                    //mantem a velocidade
                    moveVelocity = dir * movespeed * Time.deltaTime;
                }

                CalculateDirection(dir);

                animator.ChangeState(state, direction);

                changeVelocity = false;
                StopAllCoroutines();
                StartCoroutine(MoveTimer());
            }
            transform.position += moveVelocity;
        }
    }
コード例 #6
0
    // Use this for initialization
    void Start()
    {
        state = States.Attack;         //Quando nasce muda para movimento
        CalculateDirection(GameController.Instance.RandomPosition().normalized);
        animator = gameObject.GetComponentInChildren <SpriteAnimator> ();

        animator.ChangeState(state, direction);

        projectiles = new List <GameObject> ();
        nextShot    = timeBetweenShots;
        gc          = GameController.Instance;
        StartCoroutine(MoveTimer());
        transform.position = GameController.Instance.RandomPosition();
    }
コード例 #7
0
    // Use this for initialization
    void Start()
    {
        state        = States.Idle;
        animator     = gameObject.GetComponentInChildren <SpriteAnimator> ();
        line         = gameObject.GetComponentInChildren <LineRenderer> ();
        line.enabled = false;

        shootDirection = RandomDirection();
        direction      = GetEastWest(shootDirection);
        shootVector    = CalculateVec3(shootDirection);
        StartCoroutine(ShootLaser());

        animator.ChangeState(state, shootDirection);
        StartCoroutine(SequenceTimer());

        gc = GameController.Instance;
        transform.position = GameController.Instance.RandomPosition();
    }
コード例 #8
0
ファイル: GunController.cs プロジェクト: Paultsa/ManorMutiny
    // Entinen Update() kontentti siirretty tähän funktioon
    void UpdateGunController()
    {
        //Debug.Log(cooldown);
        if (GameManager.gameManager != null)
        {
            int playerIndex = 0;
            if (transform.parent.parent.CompareTag("PlayerTwo"))
            {
                playerIndex = 1;
            }
            GameManager.gameManager.players[playerIndex].chosenWeapon    = current_weapon;
            GameManager.gameManager.players[playerIndex].primaryWeapon   = weapons[0];
            GameManager.gameManager.players[playerIndex].secondaryWeapon = weapons[1];
            GameManager.gameManager.players[playerIndex].thirdWeapon     = weapons[2];
            GameManager.gameManager.players[playerIndex].ammo            = ammos[current_weapon];
            GameManager.gameManager.players[playerIndex].ammos           = ammos;
        }

        if (Input.GetKeyDown(KeyCode.E))
        {
            current_weapon = inventory_size;
            spriteAnim.ChangeState(_States.IDLE);
            gunPaths.currentWeapon = weapons[current_weapon];
        }

        //Drop weapon
        if (Input.GetKeyDown(KeyCode.G))
        {
            //KostinKoodi
            EmptySound(weapons[current_weapon]);
            weapons[current_weapon] = weapon.empty;
            ammos[current_weapon]   = -1;

            current_weapon = inventory_size;
            //weapons[inventory_size] = weapon.meleeFist;
            //ammos[inventory_size] = int.MaxValue;
            gunPaths.currentWeapon = weapon.meleeFist;
        }

        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            current_weapon         = 0;
            gunPaths.currentWeapon = weapons[current_weapon];

            if (weapons[current_weapon] == weapon.empty)
            {
                current_weapon = inventory_size;
                //weapons[inventory_size] = weapon.meleeFist;
                //ammos[inventory_size] = int.MaxValue;
                gunPaths.currentWeapon = weapon.meleeFist;
            }
        }

        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            current_weapon         = 1;
            gunPaths.currentWeapon = weapons[current_weapon];

            if (weapons[current_weapon] == weapon.empty)
            {
                current_weapon = inventory_size;
                //weapons[inventory_size] = weapon.meleeFist;
                //ammos[inventory_size] = int.MaxValue;
                gunPaths.currentWeapon = weapon.meleeFist;
            }
        }

        if (Input.GetAxis("Mouse ScrollWheel") != 0f)
        {
            current_weapon = (current_weapon == 0) ? 1 : 0;

            if (ammos[current_weapon] <= 0)
            {
                current_weapon = inventory_size;
                //weapons[inventory_size] = weapon.meleeFist;
                //ammos[inventory_size] = int.MaxValue;
            }

            gunPaths.currentWeapon = weapons[current_weapon];
        }

        ///////////

        if (Input.GetMouseButtonDown(0) &&
            ammos[current_weapon] >= 0 &&
            weapons[current_weapon] != weapon.empty &&
            cooldown <= 0 &&
            (shot == false || weapons[current_weapon] == weapon.revolver) &&
            animController.switchingWeapon == false)
        {
            spriteAnim.ChangeState(_States.SHOOT);
            shot = true;
            //cooldownTimer = spamShotCooldown;
            //spriteAnim.ChangeState(_States.SHOOT);
            Shoot(gunPaths.currentWeapon);

            ammos[current_weapon]--;
            cooldownTimer = 0;
            cooldown      = weapon_cooldown[(int)weapons[current_weapon]];
        }
        else if (ammos[current_weapon] == 0 && cooldown <= 0 && animController.switchingWeapon == false)
        {
            EmptySound(weapons[current_weapon]);
            gunPaths.currentWeapon  = weapon.empty;
            weapons[current_weapon] = weapon.empty;
            ammos[current_weapon]   = -1;
            shot = false;

            //Swap new weapon if found
            for (var i = 0; i < inventory_size; i++)
            {
                if (weapons[i] != weapon.empty)
                {
                    current_weapon         = i;
                    gunPaths.currentWeapon = weapons[current_weapon];
                    break;
                }
                current_weapon = inventory_size;
            }
        }


        if (spriteAnim.animDone && cooldownTimer >= spamShotCooldown)
        {
            gunPaths.currentWeapon = weapons[current_weapon];
            //if (ammos[current_weapon] >= 0)
            //{
            if (Input.GetMouseButton(0) && animController.switchingWeapon == false)
            {
                if (cooldown <= 0)
                {
                    if (ammos[current_weapon] > 0)
                    {
                        spriteAnim.ChangeState(_States.SHOOT);
                        Shoot(gunPaths.currentWeapon);
                        ammos[current_weapon]--;
                        cooldownTimer = 0;
                        cooldown      = weapon_cooldown[(int)weapons[current_weapon]];
                    }
                    else
                    {
                        EmptySound(weapons[current_weapon]);
                        gunPaths.currentWeapon  = weapon.empty;
                        weapons[current_weapon] = weapon.empty;
                        ammos[current_weapon]   = -1;
                        shot = false;

                        //Swap new weapon if found
                        for (var i = 0; i < inventory_size; i++)
                        {
                            if (weapons[i] != weapon.empty)
                            {
                                current_weapon         = i;
                                gunPaths.currentWeapon = weapons[current_weapon];
                                spriteAnim.ChangeState(_States.IDLE);
                                break;
                            }
                        }
                    }
                }
                else
                {
                    shot = false;
                    spriteAnim.ChangeState(_States.IDLE);
                }
            }
            else
            {
                shot = false;
                spriteAnim.ChangeState(_States.IDLE);
            }

            /*
             * }
             * else
             * {
             * shot = false;
             * spriteAnim.ChangeState(_States.IDLE);
             * }
             */
        }
        else
        {
            cooldownTimer += Time.deltaTime;
            cooldown      -= Time.deltaTime;
        }
    }
コード例 #9
0
 public void ChangeState(States state, Directions dir)
 {
     animator.ChangeState(state, dir);
 }