PowerupClass.cs :  » Game » Killer-Instinct » KillerInstinct » Sprites » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Game » Killer Instinct 
Killer Instinct » KillerInstinct » Sprites » PowerupClass.cs
using System;
using Microsoft.DirectX.DirectDraw;
using Global;
using Global.GlobalClass;
using KillerInstinct.DirectX;

namespace KillerInstinct.Sprites{
  public class PowerupClass : SpriteClass
  {
    public const int MAX_POWERUP_TYPES = 3;
    public enum PowerupType
    {
      Energy = 0,
      Shield = 1,
      Weapon = 2,
      Ammo   = 3
    }
    private PowerupType      m_powerup  = 0;  // which power-up
    private int          m_amount  = 0;  // how much of a power-up, e.g. +10 energy, -5 shields, +5 ammo, etc.
    private ShotClass.ShotTypes  m_weapon  = 0;  // for weapon and ammo power-ups, this is which weapon applies
    public int Amount
    {
      get
      { return m_amount; }
    }
    public PowerupType Powerup
    {
      get
      { return m_powerup; }
    }
    public ShotClass.ShotTypes Weapon
    {
      get
      { return m_weapon; }
    }
    public PowerupClass(float x, float y, PowerupType powerup, int amount, ShotClass.ShotTypes weapon, int deleteTime)
    {
      global.dbg.Out(Debug.DBG2, "PowerupClass called, x=[" + x + "] y=[" + y + "] powerup=[" + powerup + "] amount=[" + amount + "] weapon=[" + weapon + "] delTime=[" + deleteTime + "]");
      byte colorkey  = CONST.COLORKEY_WHITE;
      // sprite attributes
      frame.Width    = 12;
      frame.Height  = 12;
      framesCount    = 1;
      framesPerRow  = 1;
      whichFrame    = 0;
      m_powerup    = powerup;
      m_amount    = amount;
      m_weapon    = weapon;
      layer      = LAYER_POWERUP;
      //TODO: need new collision type that allows tank to collide, but shots NOT to collide
      collisionType  = CollisionType.BoundingBox;
      string powerupFile = "";
      switch (powerup)
      {
        case PowerupType.Energy:
        {
          powerupFile = CONST.BMP_POWERUP + "0.bmp";
          break;
        }
        case PowerupType.Shield:
        {
          int rShield = global.random(0, CONST.MAX_POWERUP_SHIELDS);
          powerupFile = CONST.BMP_POWERUP_SHIELD + rShield + ".bmp";
          frame.Width  = 13;
          frame.Height= 14;
          break;
        }
        case PowerupType.Weapon:
        {
          int rWeapon = global.random(0, CONST.MAX_POWERUP_WEAPONS);
          powerupFile = CONST.BMP_POWERUP_WEAPON + rWeapon + ".bmp";
          colorkey = CONST.COLORKEY_BLACK;
          frame.Width  = 13;
          frame.Height= 13;
          break;
        }
        case PowerupType.Ammo:
        {
          powerupFile = CONST.BMP_POWERUP + "3.bmp";
          break;
        }
        default:
        {
          global.dbg.Out(Debug.ERR, "PowerupClass unknown powerup type: " + powerup);
          break;
        }
      }
      //TODO: don't draw ABOVE trees, etc.
      //TODO: don't draw on top of other existing objects (except terrain objects?)
      Init(powerupFile, colorkey, x, y, deleteTime);
    }
    public override void Update()
    {
    }
    public override void ReactToCollision(SpriteClass s)
    {
      //global.dbg.Out(Debug.DBG2, "PowerupClass.ReactToCollision called, [" + s + "]");
      if (s.GetType() == typeof(TankClass))
      {
        global.spriteList.Delete(this);
        global.SC.Play(SoundClass.SOUND_POWERUP + "0.wav", false);
      }
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.