示例#1
0
 public void shootProjectile(ProjectileData projData)
 {
     try {
         PlayerGameState ownGameState = getOwnGameState();
         Monster         target       = ownGameState.monsterRef[projData.targetSerializeId];
         Vector2         source       = ownGameState.viewMapRef.getTile(projData.startCoord.row, projData.startCoord.col).transform.position;
         Projectile      proj         = projectilePool.GetProjectile();
         proj.projData       = projData;
         proj.target         = target;
         proj.source         = source;
         proj.spriteR.sprite = TowerR.getById(projData.towerId).projectileSprite;
         proj.splashR.color  = TowerR.getById(projData.towerId).splashColor;
         if (!getOpponentGameState().sendMapData)
         {
             SoundManager.instance.PlayShoot(TowerR.getById(projData.towerId).shootingSound);
         }
         proj.Initialize();
         if (getOwnGameState().sendMapData&& PhotonNetwork.connected)
         {
             photonView.RPC("shootViewProjectile", PhotonTargets.Others, projData.serialize());
         }
     } catch (KeyNotFoundException e) {
         Debug.LogWarning(e.StackTrace);
     }
 }
示例#2
0
        protected override void PerformAttack()
        {
            if (_net.IsClient)
            {
                networkView.RPC("PerformAttack", RPCMode.Server);
            }
            else
            {
                Projectile proj;
                proj = ProjectilePool.GetProjectile(ProjectilePos, transform.rotation);
                proj.transform.localScale = new Vector3(2f, 2f, 2f);
                proj.Range        = MeeleRange + 0.2f;
                proj.DoPiercing   = true;
                proj.Speed        = 13;
                proj.Player       = this;
                proj.Damage       = AttackDamage;
                proj.Knockback    = transform.forward.normalized * 8;
                proj.Knockback.y += 17.0f;
                proj.Apply();

                StartCoroutine(AttackDelay("Attacking"));
            }

            _clip[0].volume = ConfigManager.GetInstance().SoundLevel;
            _clip[0].Play();
        }
示例#3
0
        protected override void PerformAttack()
        {
            if (_net.IsClient)
            {
                networkView.RPC("PerformAttack", RPCMode.Server);
            }
            else
            {
                Projectile proj = ProjectilePool.GetProjectile(transform.position, transform.rotation);
                proj.StartPosition = this.transform.forward * 1.5f;
                proj.Range         = MeeleRange + 0.2f;
                proj.Speed         = 7;
                proj.Player        = this;
                proj.Damage        = AttackDamage;
                proj.Knockback     = Vector3.zero;
                proj.Knockback     = transform.forward.normalized * 15;
                proj.Knockback.y   = 15.0f;
                proj.DoPiercing    = true;
                proj.Apply();
            }

            _clip[0].volume = ConfigManager.GetInstance().SoundLevel;
            _clip[0].Play();
            StartCoroutine(AttackDelay("Attacking"));
        }
示例#4
0
        protected override void PerformAttack()
        {
            if (QuarryPrefab == null)
            {
                QuarryPrefab = Resources.Load("Attacks/QuarryPrefab") as GameObject;
            }

            if (_net.IsClient)
            {
                networkView.RPC("PerformAttack", RPCMode.Server);
            }
            else
            {
                Projectile proj = ProjectilePool.GetProjectile(new Vector3(0, -111, 0), transform.rotation);
                proj.StartPosition        = new Vector3(0, collider.bounds.extents.y, 0);
                proj.transform.localScale = new Vector3(1.25f, 1.25f, 1.25f);
                proj.ActivePrefab         = QuarryPrefab;
                proj.PrefabSize           = new Vector3(6f, 50f, 6f);
                proj.PrefabRotation       = new Vector3(90f, transform.localEulerAngles.y, 0);
                proj.Range       = MeeleRange + 0.2f;
                proj.Speed       = 20;
                proj.StartUp     = 0.3f;
                proj.Player      = this;
                proj.Damage      = AttackDamage;
                proj.Knockback   = Vector3.zero;
                proj.Knockback   = transform.forward.normalized * 10;
                proj.Knockback.y = 7.0f;
                proj.Apply();
            }

            _clip[0].volume = ConfigManager.GetInstance().SoundLevel;
            _clip[0].Play();
            StartCoroutine(AttackDelay("Attacking"));
        }
示例#5
0
        protected void PerformUpperCut()
        {
            if (MP < 50)
            {
                return;
            }

            if (_net.IsClient)
            {
                networkView.RPC("PerformUpperCut", RPCMode.Server);
            }
            else
            {
                Projectile proj = ProjectilePool.GetProjectile(ProjectilePos, transform.rotation);

                // proj.StartPosition = ProjectilePos + Vector3.up * -0.6f;
                proj.transform.localScale = new Vector3(2f, 2f, 2f);
                proj.StartPosition        = transform.forward.normalized * 1.5f;
                proj.ProjectileDirection  = new Vector3(0, 1f, 0);
                proj.Range       = MeeleRange + 2;
                proj.StartUp     = 0.25f;
                proj.Speed       = 13;
                proj.Player      = this;
                proj.Damage      = AttackDamage;
                proj.Knockback   = transform.forward.normalized * -6;
                proj.Knockback.y = 40.0f;
                proj.Apply();

                MP -= 50;

                StartCoroutine(AttackDelay("Special UpperCut"));
            }
        }
示例#6
0
        protected override void PerformAttack()
        {
            if (_net.IsClient)
            {
                networkView.RPC("PerformAttack", RPCMode.Server);
            }
            else
            {
                Projectile proj = ProjectilePool.GetProjectile(new Vector3(0, -111, 0), transform.rotation);
                proj.StartPosition        = new Vector3(0, collider.bounds.extents.y * 0.5f, 0);
                proj.transform.localScale = new Vector3(2, 2, 2);
                proj.Range       = MeeleRange + 0.2f;
                proj.Speed       = 15;
                proj.StartUp     = 0.3f;
                proj.Player      = this;
                proj.Damage      = AttackDamage;
                proj.Knockback   = Vector3.zero;
                proj.Knockback   = transform.forward.normalized * 15;
                proj.Knockback.y = 12.0f;
                proj.Apply();
            }

            _clip[0].volume = ConfigManager.GetInstance().SoundLevel;
            _clip[0].Play();
            StartCoroutine(AttackDelay("Attacking"));
        }
示例#7
0
    public Projectile SpawnProjectile(MagicWandOptions options, Vector3 position, Vector3 direction)
    {
        Projectile newProjectile = pool.GetProjectile();

        newProjectile.Initialize(options, position, direction);
        return(newProjectile);
    }
示例#8
0
    public Projectile SpawnProjectile(ProjectileOptions projectileOptions)
    {
        Projectile newProjectile = pool.GetProjectile();

        newProjectile.Initialize(projectileOptions);
        return(newProjectile);
    }
示例#9
0
        protected void PerformEggsplosion()
        {
            Debug.Log("Special Attack: Eggsplosion");

            if (EggsplosionPrefab == null)
            {
                EggsplosionPrefab = Resources.Load("Attacks/EggsplosionPrefab") as GameObject;
            }

            if (Projectile == null)
            {
                Projectile = Resources.Load("Attacks/EggPrefab") as GameObject;
            }

            if (MP < 50)
            {
                return;
            }

            if (_net.IsClient)
            {
                networkView.RPC("PerformEggsplosion", RPCMode.Server);
            }
            else
            {
                Projectile proj;
                proj = ProjectilePool.GetProjectile(new Vector3(0, 0, 0), transform.rotation);
                proj.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f);
                proj.StartPosition        = new Vector3(0, collider.bounds.extents.y * 0.1f, 0);
                proj.ActivePrefab         = Projectile;
                proj.PrefabSize           = new Vector3(2f, 2f, 2f);
                proj.PrefabRotation       = new Vector3(0, 270, 0);
                proj.AoEPrefab            = EggsplosionPrefab;
                proj.AoEPrefabSize        = new Vector3(6, 6, 6);
                proj.Range            = 1;
                proj.Speed            = 0f;
                proj.TimeToLive       = 1.5f;
                proj.StartUp          = 0.45f;
                proj.Player           = this;
                proj.Damage           = 0;
                proj.AoEDamage        = true;
                proj.AoEKnockbackVert = Vector3.up * 30;
                proj.AoEKnockbackHor  = 20;
                proj.AoEDamageValue   = AttackDamage + 20;
                proj.AoESize          = new Vector3(10, 10, 10);
                proj.AoETime          = 1;
                proj.Knockback.y      = 8.0f;
                proj.Apply();

                IsKnockbackImmune = true;
                IsDamageImmune    = true;

                MP -= 60;

                StartCoroutine(AttackDelay("Special Eggsplosion"));
            }
        }
示例#10
0
        protected void PerformDropKick()
        {
            if (MP < 80)
            {
                return;
            }

            if (_net.IsClient)
            {
                networkView.RPC("PerformDropKick", RPCMode.Server);
            }
            else
            {
                Projectile proj = ProjectilePool.GetProjectile(ProjectilePos, transform.rotation);
                proj.transform.localScale = new Vector3(3f, 3f, 3f);
                proj.StartPosition        = transform.forward.normalized * 2f;
                proj.ProjectileDirection  = new Vector3(0, 0, 0);
                proj.Attached             = true;
                proj.Range       = MeeleRange;
                proj.Speed       = 0;
                proj.TimeToLive  = 0.55f;
                proj.Player      = this;
                proj.PlayerObj   = this.gameObject;
                proj.DoPiercing  = true;
                proj.Damage      = AttackDamage - 20;
                proj.Knockback   = transform.forward.normalized * 25;
                proj.Knockback.y = 15.0f;
                proj.Apply();
                CanMove     = true;
                IsDefending = false;

                IsAttacking = true;
                IsJumping   = true;

                IsKnockbackImmune = true;

                MP -= 80;

                animation.Play("Special DropKick");
                if (_net.IsServer)
                {
                    networkView.RPC("NetworkPlayAnimation",
                                    RPCMode.Others,
                                    "Special DropKick",
                                    -1f,
                                    false);
                }
            }

            if (IsMine())
            {
                Vector3 dir = transform.forward.normalized * 25;
                dir.y     = 15;
                Direction = dir;
                Move();
            }
        }
示例#11
0
    public void SpawnEnemyProjectile(Vector3 position, Vector2 direction, Quaternion rotation, Vector3 enemyShipVelocity)
    {
        Projectile newProjectile = enemyProjectilePool.GetProjectile();

        newProjectile.transform.position = position;
        newProjectile.transform.rotation = rotation;
        //Projectile newProjectile = Instantiate(projectilePrefab, position, rotation);
        //newProjectile.gameObject.SetActive(true);
        newProjectile.Init(lifeTime, enemySpeed, direction, enemyShipVelocity);
    }
        private void Update()
        {
            Projectile projectile = null;

            if (Input.GetKeyUp(KeyCode.Alpha1))
            {
                projectile = pool.GetProjectile(ProjectilePool.ProjectileTypes.Player)?.GetComponent <Projectile>();
            }
            else if (Input.GetKeyUp(KeyCode.Alpha2))
            {
                projectile = pool.GetProjectile(ProjectilePool.ProjectileTypes.Enemy)?.GetComponent <Projectile>();
            }

            if (projectile != null)
            {
                projectile.transform.position      = this.transform.position;
                projectile.transform.localRotation = this.transform.localRotation;
            }
        }
示例#13
0
    public void SpawnProjectile(Vector3 position, Vector2 direction, Quaternion rotation)
    {
        Projectile newProjectile = pool.GetProjectile();

        newProjectile.transform.position = position;
        newProjectile.transform.rotation = rotation;
        //Projectile newProjectile = Instantiate(projectilePrefab, position, rotation);
        //newProjectile.gameObject.SetActive(true);
        newProjectile.Init(lifeTime, speed, direction, playerRb2d.velocity);
        SoundManager.main.PlaySound(SoundType.ShootCannon);
    }
示例#14
0
 protected void Attack(List <BaseEntity> enemies)
 {
     if (_canAttack)
     {
         _canAttack = false;
         BaseProjectile newProjectile = _projectilePool.GetProjectile(projectile.GetProjectileType());
         newProjectile.MoveTo(transform.position);
         newProjectile.transform.SetParent(transform);
         newProjectile.Launch(enemies[0]);
         StartCoroutine(AttackCooldown(GetCooldown()));
     }
 }
示例#15
0
    void Fire()
    {
        GameObject o = pool.GetProjectile();

        if (o != null)
        {
            audio.pitch = 1 + Random.Range(-0.1f, 0.1f);
            audio.Play();
            o.transform.position = transform.position;
            o.GetComponent <Projectile>().right = p2D.FacingRight;
            o.GetComponent <Projectile>().pool  = pool;
        }
    }
示例#16
0
        protected void PerformSplashAttack()
        {
            Debug.Log("Special Attack: Splash");

            if (Projectile == null)
            {
                Projectile = Resources.Load("Attacks/EggPrefab") as GameObject;
            }

            if (EggPartPrefab == null)
            {
                EggPartPrefab = Resources.Load("Attacks/EggPartPrefab") as GameObject;
            }

            if (MP < 30)
            {
                return;
            }

            if (_net.IsClient)
            {
                networkView.RPC("PerformSplashAttack", RPCMode.Server);
            }
            else
            {
                Projectile proj = ProjectilePool.GetProjectile(ProjectilePos, transform.rotation);
                proj.transform.localScale = new Vector3(1f, 1f, 1f);
                proj.PrefabSize           = new Vector3(0.6f, 0.6f, 0.6f);
                proj.StartPosition        = new Vector3(0, collider.bounds.extents.y * 1.5f, 0);
                proj.ActivePrefab         = Projectile;
                proj.PrefabRotation       = new Vector3(0, 270, 0);
                proj.Range                 = MeeleRange - 0.8f;
                proj.Speed                 = 20;
                proj.StartUp               = 0.25f;
                proj.Player                = this;
                proj.Damage                = AttackDamage;
                proj.HasGravity            = true;
                proj.ProjectileDirection.y = 0.1f;
                proj.Knockback             = transform.forward.normalized * 10;
                proj.Knockback.y           = 8.0f;
                proj.ForkDamage            = true;
                proj.ForkArcRadius         = 7.0f;
                proj.ForkPrefab            = EggPartPrefab;
                proj.Apply();

                MP -= 40;

                StartCoroutine(AttackDelay("Attacking"));
            }
        }
示例#17
0
        /// <summary>
        /// performs a standart attack
        /// </summary>
        protected override void PerformAttack()
        {
            Projectile proj = ProjectilePool.GetProjectile(new Vector3(0, -111, 0), transform.rotation);

            proj.StartPosition        = new Vector3(0, collider.bounds.extents.y * 0.5f, 0);
            proj.transform.localScale = new Vector3(2, 2, 2);
            proj.Range       = MeeleRange + 2.5f;
            proj.Speed       = 20;
            proj.StartUp     = 0.3f;
            proj.Player      = this;
            proj.Damage      = AttackDamage + BasicDamage;
            proj.Knockback   = transform.forward.normalized * 5;
            proj.Knockback.y = 15.0f;
            proj.Apply();

            StartCoroutine(AttackDelay("Attacking"));
        }
示例#18
0
        protected void PerformMultiShotAttack()
        {
            Debug.Log("Special Attack: MultiShot");

            if (Projectile == null)
            {
                Projectile = Resources.Load("Attacks/EggPrefab") as GameObject;
            }

            if (MP < 25)
            {
                return;
            }

            if (_net.IsClient)
            {
                networkView.RPC("PerformMultiShotAttack", RPCMode.Server);
            }
            else
            {
                for (int i = 0; i < 3; i++)
                {
                    Projectile proj = ProjectilePool.GetProjectile(ProjectilePos, transform.rotation);
                    proj.transform.localScale = new Vector3(1.3f, 1.3f, 1.3f);
                    proj.PrefabSize           = new Vector3(0.8f, 0.8f, 0.8f);
                    proj.StartPosition        = new Vector3(0, collider.bounds.extents.y * 1.5f, 0);
                    proj.ActivePrefab         = Projectile;
                    proj.PrefabRotation       = new Vector3(0, 270, 0);
                    proj.Range       = 20;
                    proj.Speed       = 20;
                    proj.StartUp     = 0.25f + (0.6f * i);
                    proj.Player      = this;
                    proj.Damage      = AttackDamage - 10;
                    proj.Knockback   = Vector3.zero;
                    proj.Knockback.y = 19.0f;
                    proj.Apply();

                    IsKnockbackImmune = true;

                    MP -= 40;

                    StartCoroutine(AttackDelay("Special MultiShot"));
                }
            }
        }
示例#19
0
        protected void PerformHammer()
        {
            if (EarthquakePrefab == null)
            {
                EarthquakePrefab = Resources.Load("Attacks/EarthquakePrefab") as GameObject;
            }

            if (MP < 60)
            {
                return;
            }

            if (_net.IsClient)
            {
                networkView.RPC("PerformHammer", RPCMode.Server);
            }
            else
            {
                Projectile proj = ProjectilePool.GetProjectile(ProjectilePos, transform.rotation);
                proj.StartPosition        = Vector3.up * 3;
                proj.transform.localScale = new Vector3(2f, 2f, 2f);
                proj.ProjectileDirection  = new Vector3(proj.ProjectileDirection.x, -1.5f, proj.ProjectileDirection.z);
                proj.AoEPrefab            = EarthquakePrefab;
                proj.AoEPrefabSize        = new Vector3(1.0f, 1.0f, 1.0f);
                proj.AoEPrefabRotation    = new Vector3(270f, 0, 0);
                proj.Range            = 2.5f;
                proj.Speed            = 9f;
                proj.StartUp          = 0.35f;
                proj.Player           = this;
                proj.DoPiercing       = true;
                proj.Damage           = AttackDamage + 40;
                proj.Knockback        = transform.forward.normalized * 25;
                proj.Knockback.y      = 30.0f;
                proj.AoEDamage        = true;
                proj.AoEKnockbackVert = Vector3.up * 20;
                proj.AoESize          = new Vector3(10.0f, 1f, 10.0f);
                proj.AoEDamageValue   = AttackDamage / 4;
                proj.AoETime          = 0.5f;
                proj.Apply();

                MP -= 60;

                StartCoroutine(AttackDelay("Special Hammer"));
            }
        }
    // Update is called once per frame
    void Update()
    {
        Vector3 movement = GetMovement();

        //Debug.Log(movement);
        //Debug.Log(movement.normalized);
        //rb.velocity = movement * speed;
        transform.position += movement * speed * Time.deltaTime;

        if (GetFire() && Time.time > timeToNextFire && GameManager.instance.gameStarted)
        {
            timeToNextFire = Time.time + fireSpeed;
            Projectile clone;
            clone = projectilePool.GetProjectile();
            clone.transform.position = spawnPoint.transform.position;
            clone.gameObject.SetActive(true);
        }
    }
示例#21
0
        protected override void PerformAttack()
        {
            if (Projectile == null)
            {
                Projectile = Resources.Load("Attacks/EggPrefab") as GameObject;
            }

            if (_net.IsClient)
            {
                networkView.RPC("PerformAttack", RPCMode.Server);
            }
            else
            {
                Projectile proj;
                proj = ProjectilePool.GetProjectile(new Vector3(0, -1000, 0), transform.rotation);
                proj.transform.localScale = new Vector3(1f, 1f, 1f);
                proj.StartPosition        = new Vector3(0, collider.bounds.extents.y * 1.5f, 0);
                proj.ActivePrefab         = Projectile;
                Debug.Log(proj.ActivePrefab);
                proj.PrefabSize            = new Vector3(0.5f, 0.5f, 0.5f);
                proj.PrefabRotation        = new Vector3(0, 270, 0);
                proj.ProjectileDirection.y = 0.1f;
                proj.Range       = MeeleRange + 1.2f;
                proj.Speed       = 20;
                proj.StartUp     = 0.35f;
                proj.Player      = this;
                proj.HasGravity  = true;
                proj.Damage      = AttackDamage;
                proj.Knockback   = transform.forward.normalized * 10f;
                proj.Knockback.y = 10.0f;
                proj.Apply();

                StartCoroutine(AttackDelay("Attacking"));
            }

            // _clip[0].volume = ConfigManager.GetInstance().SoundLevel;
            // _clip[0].Play();
        }
示例#22
0
    // Update is called once per frame
    void Update()
    {
        if (gameManager.IsPaused())
        {
            return;
        }

        if (shotTimerCountdown > 0)
        {
            shotTimerCountdown -= Time.deltaTime;
            if (shotTimerCountdown <= 0)
            {
                shotsFired = 0;
            }
        }

        //interaction
        if (Input.GetButtonDown("Submit"))
        {
            if (nextToShop)
            {
                //trigger shop
                gameManager.OpenShop();
            }
            else if (nextToWeapons)
            {
                //trigger weapon shop
                gameManager.OpenWeapons();
            }
        }
        else if (Input.GetKeyDown("escape"))
        {
            gameManager.OpenQuitPanel();
        }

        if (invulnerabityTimerCountdown > 0)
        {
            invulnerabityTimerCountdown -= Time.deltaTime;
            invulnerabilityFlashTimer   -= Time.deltaTime;
            if (invulnerabilityFlashTimer < -0.10f)
            {
                invulnerabilityFlashTimer = -invulnerabilityFlashTimer;
            }
            if (invulnerabityTimerCountdown <= 0)
            {
                Color c = spriteRenderer.color;
                c.a = 1.0f;
                invulnerabityTimerCountdown = 0;
                spriteRenderer.color        = c;
            }
            else
            {
                float alpha = 0.5f + Mathf.Abs(invulnerabilityFlashTimer) * 5;
                Color c     = spriteRenderer.color;
                c.a = alpha;
                spriteRenderer.color = c;
            }
        }

        if (isUnderWater)
        {
            //Bubbles
            bubbleTimerCountDown -= Time.deltaTime;
            if (bubbleTimerCountDown <= 0)
            {
                //start a bubble
                bubbles[bubbleIndex].gameObject.transform.position = gameObject.transform.position;
                bubbles[bubbleIndex].PlayBubble();
                bubbleIndex++;
                if (bubbleIndex >= bubbles.Length)
                {
                    bubbleIndex = 0;
                }

                bubbleTimerCountDown = bubbleTimer;
            }

            //Oxygen
            currentOxygen -= Time.deltaTime * oxygenRate;
            if (currentOxygen <= 0)
            {
                currentOxygen = 0;
                gameManager.Death((int)-transform.position.y - 6, GameManager.DeathType.Air);
            }

            dudeRigidBody.gravityScale = 0.25f;

            Vector2 movementInput = dudeRigidBody.velocity;

            if (damageShock)
            {
                //shock movement
                movementInput.y = waterJumpSpeed;
                damageShock     = false;
            }
            else
            {
                //Jumping
                if (Input.GetButtonDown("Jump") && !nextToShop && !nextToWeapons)
                {
                    movementInput.y = waterJumpSpeed;
                }

                //Running
                float horizontalMovement = Input.GetAxis("Horizontal");
                movementInput.x = horizontalMovement * waterMoveSpeed;

                //"Swimming" Animations
                if (movementInput.y > 0)
                {
                    SetAnimationState(SpriteAnimationState.Jumping);
                }
                else
                {
                    SetAnimationState(SpriteAnimationState.Falling);
                }

                if (horizontalMovement > 0)
                {
                    spriteRenderer.flipX = false;
                    facingLeft           = false;
                }
                else if (horizontalMovement < 0)
                {
                    spriteRenderer.flipX = true;
                    facingLeft           = true;
                }
            }

            if (movementInput.y < -maxFallSpeed)
            {
                movementInput.y = -maxFallSpeed;
            }

            dudeRigidBody.velocity = movementInput;
        }
        else
        {
            //Oxygen
            if (currentOxygen < maxOxygen)
            {
                currentOxygen = maxOxygen;
            }

            dudeRigidBody.gravityScale = 1;

            Vector2 movementInput = dudeRigidBody.velocity;

            if (damageShock)
            {
                //shock movement
                movementInput.y = jumpSpeed;
                damageShock     = false;
            }
            else
            {
                //Jumping
                if (Input.GetButtonDown("Jump") && isOnGround && !nextToShop && !nextToWeapons)
                {
                    isOnGround      = false;
                    movementInput.y = jumpSpeed;
                }

                //Running
                float horizontalMovement = Input.GetAxis("Horizontal");
                movementInput.x = horizontalMovement * moveSpeed;

                //Animation
                if (isOnGround)
                {
                    //Running Animations
                    if (horizontalMovement != 0)
                    {
                        SetAnimationState(SpriteAnimationState.Running);
                        if (horizontalMovement > 0)
                        {
                            spriteRenderer.flipX = false;
                            facingLeft           = false;
                        }
                        else
                        {
                            spriteRenderer.flipX = true;
                            facingLeft           = true;
                        }
                    }
                    else
                    {
                        SetAnimationState(SpriteAnimationState.Standing);
                    }
                }
                else
                {
                    //Jumping Animations
                    if (movementInput.y > 0)
                    {
                        SetAnimationState(SpriteAnimationState.Jumping);
                    }
                    else
                    {
                        SetAnimationState(SpriteAnimationState.Falling);
                    }

                    if (horizontalMovement > 0)
                    {
                        spriteRenderer.flipX = false;
                        facingLeft           = false;
                    }
                    else if (horizontalMovement < 0)
                    {
                        spriteRenderer.flipX = true;
                        facingLeft           = true;
                    }
                }
            }

            if (movementInput.y < -maxFallSpeed)
            {
                movementInput.y = -maxFallSpeed;
            }

            dudeRigidBody.velocity = movementInput;
        }

        //interaction
        if (Input.GetButtonDown("Fire1"))
        {
            if (shotsFired < currentShotCount)
            {
                int numProjectiles = 1;
                if (multiShot)
                {
                    numProjectiles = 3;
                }

                for (int i = 0; i < numProjectiles; i++)
                {
                    float offset = 0;
                    if (i == 1)
                    {
                        offset = 0.5f;
                    }
                    else if (i == 2)
                    {
                        offset = -0.5f;
                    }

                    float stagger = 0;
                    if (i > 0)
                    {
                        stagger = 0.5f;
                    }

                    Projectile projectile;
                    if (Input.GetAxis("Vertical") > 0)
                    {
                        projectile = projectilePool.GetProjectile(1);

                        Vector3 position = transform.position;
                        position.x += offset;
                        position.y -= stagger;
                        projectile.transform.position = position;
                        projectile.SetDirection(new Vector3(0, currentFiringSpeed, 0));
                    }
                    else if (Input.GetAxis("Vertical") < 0)
                    {
                        projectile = projectilePool.GetProjectile(1);

                        Vector3 position = transform.position;
                        position.x += offset;
                        position.y += stagger;
                        projectile.transform.position = position;
                        projectile.SetDirection(new Vector3(0, -currentFiringSpeed, 0));
                    }
                    else
                    {
                        projectile = projectilePool.GetProjectile(0);

                        if (facingLeft)
                        {
                            Vector3 position = transform.position;
                            position.x += stagger;
                            position.y += offset;
                            projectile.transform.position = position;
                            projectile.SetDirection(new Vector3(-currentFiringSpeed, 0, 0));
                        }
                        else
                        {
                            Vector3 position = transform.position;
                            position.x -= stagger;
                            position.y += offset;
                            projectile.transform.position = position;
                            projectile.SetDirection(new Vector3(currentFiringSpeed, 0, 0));
                        }
                    }

                    projectile.SetAttack(GetAttack());
                    projectile.SetDude(this);
                }

                if (shotsFired == 0)
                {
                    shotTimerCountdown = shotTimer;
                }
                shotsFired++;
            }
        }
    }
示例#23
0
 protected override void Shoot(ProjectilePool pool, Vector3 position, Vector3 direction)
 {
     pool.GetProjectile(this._transform.position, direction);
     pool.GetProjectile(this._transform.position, direction.Rotate(20f));
     pool.GetProjectile(this._transform.position, direction.Rotate(-20f));
 }
示例#24
0
文件: Gfx.cs 项目: Metfield/HunTest
    public void FireProjectile(Vector2 origin, float direction)
    {
        Projectile projectile = projectilePool.GetProjectile();

        projectile.Fire(origin, direction * 1000);
    }
示例#25
0
 protected virtual void Shoot(ProjectilePool pool, Vector3 position, Vector3 direction)
 {
     pool.GetProjectile(this._transform.position, direction);
 }
示例#26
0
 protected virtual void Shoot(ProjectilePool pool, Vector2 position, Vector2 direction)
 {
     pool.GetProjectile(position, direction);
 }