ShotAlternativClass.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 » ShotAlternativClass.cs
using System;
using Microsoft.DirectX.DirectDraw;
using Global;
using Global.GlobalClass;
using KillerInstinct.DirectX;

namespace KillerInstinct.Sprites{
  public class ShotAlternativClass : SpriteClass
  {
    public const int RANGE = 200;
    // shot types
    public enum AltShotTypes
    {
      None    = 69,      // should produce an error if accessing an array, file, etc.
      AltBasic  = 10,
      AltL2    = 11,
      AltL3    = 12,
      AltL4    = 13
    }
    private AltShotTypes m_shotType = AltShotTypes.AltBasic;
    private float    m_x, m_y;
    public  float    speedCount;
    public  int      damage = 0;
    public  int      range  = 0;
    private byte    m_colorkey  = CONST.COLORKEY_WHITE;
    // returns type of SECONDARY (alternative) shot
    public AltShotTypes ShotType
    {
      get
      { return m_shotType; }
    }
    public ShotAlternativClass(AltShotTypes shotType, float x, float y, ulong parentId)
    {
      this.parentId  = parentId;
      // sprite attributes
      frame.Width    = 5;
      frame.Height  = 5;
      framesCount    = 1;
      framesPerRow  = 1;
      // starting direction
      whichFrame    = 0;
      m_x        = x;
      m_y        = y;
      // staring speed
      speed      = 3f;
      // collisionType
      collisionType  = CollisionType.NoCollision;
      // to be in range
      speedCount    = speed;
      range      = 200;
      m_shotType    = shotType;
      layer      = LAYER_SHOT;
      // determine other shot type specific information
      switch (shotType)
      {
        // alternate basic shot
        case AltShotTypes.AltBasic:
          range  = 175;
          speed  = 3f;
          break;
        // alternate shot level 2
        case AltShotTypes.AltL2:
          range  = 200;
          speed  = 4f;
          break;
        // alternate shot level 3
        case AltShotTypes.AltL3:
          range  = 250;
          speed  = 5f;
          break;
        // alternate shot level 4
        case AltShotTypes.AltL4:
          frame.Width    = 15;
          frame.Height  = 15;
          framesCount    = 3;
          framesPerRow  = 3;
          range  = 350;
          speed  = 2.5f;
          m_colorkey = CONST.COLORKEY_BLACK;
          break;
        default:
          global.dbg.Out(Debug.ERR, "AltShotClass undefined shot type: [" + shotType + "].");
          break;
      }
      Init(CONST.BMP_SHOT + (int)shotType + ".bmp", m_colorkey, x, y);
    }
    public override void Update()
    {
      posX = posX + speed * (float)Math.Cos(direction*Math.PI/180);
      posY = posY + speed * (float)Math.Sin(direction*Math.PI/180);
      speedCount += speed;
      if ((posX<0) || (posX>global.options.SCR_WIDTH-frame.Width)   || 
        (posY<0) || (posY>global.options.SCR_HEIGHT-frame.Height) ||
        (speedCount > range))
        global.spriteList.Delete(this);
      if ((Math.Abs(m_x-posX)>35) || (Math.Abs(m_y-posY)>35)) 
        collisionType = CollisionType.BoundingBox;
      // glowing red shot
      if (ShotType == AltShotTypes.AltL4)
      {
        if (whichFrame < framesCount-1) whichFrame++;
        else whichFrame = 0;
      }
    }
    public override void ReactToCollision(SpriteClass s)
    {
      // if one of the sprites _IS_ the other persons parent...
      //if (this.globalId != s.parentId && this.parentId != s.globalId)
      // 
      if (this.parentId != s.globalId)
      {
        global.dbg.Out(Debug.DBG2, "ShotAlternativClass.ReactToCollision called [" + s + "]");
        if (s.collisionType != CollisionType.NoCollision)
        {
          global.spriteList.Delete(this);
          global.SC.Play(SoundClass.SOUND_ALTHIT, false);
        }
        //TODO:??else if (s.GetType() == typeof())
        {
        }
      }
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.