Exemple #1
0
 // used by Factory to recycle Bullet objects.
 public void Reinitialize(Controller pController, Gun pOwnerGun, Int32 pColorIndex)
 {
     controller = pController;
     OwnerGun = pOwnerGun;
     colorIndex = pColorIndex;
     framesAlive = 0;
     bulletMesh.MaterialName = Constants.DamageMaterialNames[pColorIndex];
 }
        public static Bullet NewBullet(Controller pController, Gun pOwnerGun, Int32 pColorIndex)
        {
            if (freeBullets.Count == 0)
            {
                return new Bullet(pController, pOwnerGun, pColorIndex);
            }

            var bullet = freeBullets.Dequeue();
            bullet.Reinitialize(pController, pOwnerGun, pColorIndex);
            return bullet;
        }
Exemple #3
0
        public Bullet(Controller pController, Gun pOwnerGun, Int32 pColorIndex)
            : base(pController)
        {
            var bulletname = Methods.GenerateUniqueID.ToString();

            Node = World.Instance.SceneManager.RootSceneNode.CreateChildSceneNode(bulletname);
            Node.IsVisible = false;
            MeshNode = Node.CreateChildSceneNode();
            MeshNode.Scale = new Vector3(0.3, 0.3, 0.3);
            bulletMesh = World.Instance.SceneManager.CreateEntity(bulletname, "bullet.mesh");
            MeshNode.AttachObject(bulletMesh);

            Reinitialize(pController, pOwnerGun, pColorIndex);
        }