Ejemplo n.º 1
0
    private void CreateAmmoOnCell(MazeCell cell)
    {
        AmmoPack ammo = Instantiate(ammoPrefab) as AmmoPack;

        cell.ammoOnCell = true;
        ammo.transform.localPosition = cell.transform.localPosition;
        ammo.transform.parent        = cell.transform;
        ammo.name = "Ammo " + cell.transform.localPosition.x + ", " + cell.transform.localPosition.z;
        cell.ammo = ammo;
        ammo.StartMovingPack();
    }
Ejemplo n.º 2
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        AmmoPack ammoPack = (AmmoPack)target;

        if (GUILayout.Button("Generate ID"))
        {
            ammoPack.ammoID = System.Guid.NewGuid().ToString();
            EditorUtility.SetDirty(ammoPack);
        }
    }
Ejemplo n.º 3
0
        private void CreateObject(TmxObject obj, Rectangle source, TmxTileset tileset, Texture2D tilesetTexture)
        {
            var    random        = new Random();
            var    type          = tileset.Tiles[obj.Tile.Gid - tileset.FirstGid].Type;
            var    rotation      = MathHelper.ToRadians((float)obj.Rotation);
            var    spawnPosition = GetObjectPosition(obj, source);
            Entity entity;

            switch (type)
            {
            case "Car":
                entity = new Car(this, tilesetTexture, (int)obj.Width, (int)obj.Height, spawnPosition,
                                 rotation, source);
                break;

            case "Enemy_Spawn":
                entity = new Enemy(tilesetTexture, spawnPosition, (int)obj.Width, (int)obj.Height, this,
                                   rotation, source);
                break;

            case "Dungeon_Entrance":
                entity = new DungeonEntrance(new ShooterScreen(), screenManager, tilesetTexture, (int)obj.Width,
                                             (int)obj.Height, spawnPosition, rotation, source);
                break;

            case "Collectable":
                entity = new Collectable(tilesetTexture, spawnPosition, (int)obj.Width, (int)obj.Height, rotation, source);
                break;

            case "Ammo":
                var randomBulletType = (BulletType)random.Next(Enum.GetNames(typeof(BulletType)).Length);
                entity = new AmmoPack(randomBulletType, random.Next(15, 30), tilesetTexture, spawnPosition,
                                      (int)obj.Width, (int)obj.Height, rotation, source);
                break;

            case "Health":
                entity = new HealthPack(random.Next(15, 30), tilesetTexture, spawnPosition, (int)obj.Width,
                                        (int)obj.Height, rotation, source);
                break;

            case "Gas":
                entity = new GasPump(tilesetTexture, (int)obj.Width, (int)obj.Height, spawnPosition, rotation, source);
                break;

            default:
                entity = new Entity(tilesetTexture, (int)obj.Width, (int)obj.Height, spawnPosition, rotation,
                                    source);
                break;
            }

            EntityManager.Instance.AddEntity(entity);
        }
Ejemplo n.º 4
0
    //handles collisions
    void OnTriggerEnter2D(Collider2D col)
    {
        Enemy    enemy = col.GetComponent <Enemy>();
        AmmoPack other = col.GetComponent <AmmoPack>();

        if (enemy != null)
        {
            DamagePlayer(2);
        }
        else if (other != null)
        {
            playerHealth += other.ammo_count;
        }
    }