コード例 #1
0
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            // TODO: Add your initialization code here
            foods = new List <food>();
            Vector2 startLoc = new Vector2(10, 10);

            xOffset = 150;
            yOffset = 150;

            for (int i = 0; i < foodGrid.X; i++)
            {
                for (int ii = 0; ii < foodGrid.Y; ii++)
                {
                    food f = new NoWeapon(g);
                    f.Initialize();
                    f.Location = new Vector2(startLoc.X + (xOffset * i), startLoc.Y + (yOffset * ii));
                    foods.Add(f);
                }
            }
            food r = new RedWeapon(g);

            r.Initialize();
            r.Location = new Vector2(200, 200);
            foods.Add(r);
            r = new TealWeapon(g);
            r.Initialize();
            r.Location = new Vector2(300, 200);
            foods.Add(r);
            sb = new SpriteBatch(Game.GraphicsDevice);
            base.Initialize();
        }
コード例 #2
0
    internal override void Start()
    {
        base.Start();
        animator    = GetComponent <Animator>();
        isAttacking = false;

        Weapon = new NoWeapon();
    }
コード例 #3
0
 public override void Update()
 {
     _heroPassive = new Ability(AbilityList.DragonBreath, false, 250, this);
     _idleTimer   = 0;
     if (!isInitialized)
     {
         isFlying       = true;
         _armor         = 9999;
         _range         = 0;
         _hp            = 500;
         _damage        = 35;
         _gun           = new NoWeapon(GameScene.Instance);
         _cooldownValue = 10;
         _speed         = 2;
     }
     base.Update();
     if (_cooldown <= 0 && !Global.isGamePaused)
     {
         _heroPassive.Effect();
         _cooldown = _cooldownValue;
     }
 }
コード例 #4
0
ファイル: Weapon.cs プロジェクト: Studio-14/JungleDash
    // Update is called once per frame
    void Update()
    {
        //assigns weapon input source
        weaponInput = Input.GetAxisRaw("Weapon");
        //attack input
        if (weaponInput >= 1)
        {
            Attack();
        }
        //timer between attacks
        timer += Time.deltaTime;

        SelectedWeapon();

        //Hides from player the other weapons depending on current weapon
        //stick 1
        if (Weapons[0])
        {
            Stick.SetActive(true);
            Stick2.SetActive(false);
            Gun.SetActive(false);
            NoWeapon.SetActive(false);
        }
        //stick 2
        else if (Weapons[1])
        {
            Stick.SetActive(false);
            Stick2.SetActive(true);
            Gun.SetActive(false);
            NoWeapon.SetActive(false);
        }
        //bamboo blow gun
        else if (Weapons[2])
        {
            Stick.SetActive(false);
            Stick2.SetActive(false);
            Gun.SetActive(true);
            NoWeapon.SetActive(false);

            //flips the gun sprite with the player when they turn around
            if (player.GetComponent <SpriteRenderer>().flipX == true)
            {
                gameObject.transform.rotation = Quaternion.Euler(0, 0, 222);
            }
            else
            {
                gameObject.transform.rotation = Quaternion.Euler(0, 0, 45);
            }
            //increases dartspeed and lowers timer between dart discharge when active
            if (PlayerPrefsManager.ReturnRapidFire() == "true")
            {
                DartSpeed = 15;
                maxTimer  = 0.25f;
            }
            else
            {
                DartSpeed = 10;
                maxTimer  = 0.5f;
            }
        }
        //no weapon
        else if (Weapons[3])
        {
            Stick.SetActive(false);
            Stick2.SetActive(false);
            Gun.SetActive(false);
            NoWeapon.SetActive(true);
        }
    }