Ejemplo n.º 1
0
 public void SetBulletType(int index, EntityBullet.EntityBulletType type)
 {
     if (bullets.Count > index)
     {
         bullets[index] = type;
     }
 }
Ejemplo n.º 2
0
    GameObject InstantiateVisualBulletGoFromBulletType(EntityBullet.EntityBulletType type)
    {
        GameObject ret = null;

        GameObject prefab = null;

        switch (type)
        {
        case EntityBullet.EntityBulletType.HIT_MOVE_TILE:
            prefab = LevelCreatorEditor.Instance.GetBulletAmmoHitMove();
            break;

        case EntityBullet.EntityBulletType.HIT_STATIC_TILE:
            prefab = LevelCreatorEditor.Instance.GetBulletAmmoHitStatic();
            break;
        }

        if (prefab != null)
        {
            ret = Instantiate(prefab, new Vector3(0, 0, 0), Quaternion.identity);
            ret.transform.parent = transform;
        }

        return(ret);
    }
Ejemplo n.º 3
0
    public bool Shoot()
    {
        bool ret = false;

        if (timer_before_new_shoot.ReadTime() > time_before_new_shoot)
        {
            if (path != null && GetBulletsCount() > 0)
            {
                EntityPathInstance.PathPoint point = path.GetPathPointFromEntityGo(gameObject);

                EntityBullet.EntityBulletType type = GetNextBullet();

                GameObject   bullet        = InstantiateBulletGoFromBulletType(type);
                EntityBullet bullet_script = bullet.AddComponent <EntityBullet>();
                bullet_script.Init(this, LevelCreatorEditor.Instance.GetBulletsSpeed(), type);

                RemoveNextBullet();

                timer_before_new_shoot.Start();

                EventManager.Event ev = new EventManager.Event(EventManager.EventType.ENTITY_SHOOTS);
                ev.entity_shoots.entity = this;
                EventManager.Instance.SendEvent(ev);

                ret = true;
            }
        }

        return(ret);
    }
Ejemplo n.º 4
0
    public EntityBullet.EntityBulletType GetNextBullet()
    {
        EntityBullet.EntityBulletType ret = new EntityBullet.EntityBulletType();

        if (bullets.Count > 0)
        {
            ret = bullets[0];
        }

        return(ret);
    }
Ejemplo n.º 5
0
    private bool BulletCanDestroyTile(EntityBullet.EntityBulletType bullet_type, GameGridInstance.GridTileType tile_type)
    {
        bool ret = false;

        if (bullet_type == EntityBullet.EntityBulletType.HIT_MOVE_TILE && tile_type == GameGridInstance.GridTileType.GRID_TILE_TYPE_MOVE)
        {
            ret = true;
        }

        if (bullet_type == EntityBullet.EntityBulletType.HIT_STATIC_TILE && tile_type == GameGridInstance.GridTileType.GRID_TIILE_TYPE_STATIC)
        {
            ret = true;
        }

        return(ret);
    }
Ejemplo n.º 6
0
    public override void OnInspectorGUI()
    {
        BasicLevel myScript = (BasicLevel)target;

        if (!Application.isPlaying)
        {
            DrawDefaultInspector();

            List <EntityBullet.EntityBulletType> bullets = myScript.GetBulletsList();
            int bullets_number = bullets.Count;

            GUILayout.Label("Bullets elements ========");

            bullets_number = EditorGUILayout.IntField("Bullets number", bullets_number);

            if (bullets_number != bullets.Count)
            {
                myScript.SetBulletsNumber(bullets_number);

                EditorUtility.SetDirty(target);
            }

            bullets = myScript.GetBulletsList();

            for (int i = 0; i < bullets.Count; ++i)
            {
                EntityBullet.EntityBulletType curr_bullet = bullets[i];

                string name = "Bullet " + (i + 1);

                EntityBullet.EntityBulletType obj = (EntityBullet.EntityBulletType)EditorGUILayout.EnumPopup(name, curr_bullet);

                if (obj != curr_bullet)
                {
                    myScript.SetBulletType(i, obj);

                    EditorUtility.SetDirty(target);
                }
            }
        }
    }