Ejemplo n.º 1
0
    //happens when stairs move
    public void ShiftIndex(int dir)
    {
        PickableItem.Type t = PickableItem.Type.COIN;
        for (int i = 0; i < spawned.Count; i++)
        {
            //Check world position
            if (spawned [i].obj.transform.position != stairs.GetStepPosition(spawned [i].at))
            {
                spawned [i].obj.transform.position = stairs.GetStepPosition(spawned [i].at);
            }

            spawned [i].at += dir;
            spawned [i].item.SetPlace(spawned[i].at);
            //Debug.Log (i + ". " + spawned [i].obj.name + " at " + spawned [i].pos);
        }
        for (int i = 0; i < spawned.Count; i++)
        {
            if (spawned [i].at == 0 || spawned[i].type != PickableItem.Type.CRYSTAL && spawned[i].at < 0)
            {
                spawned [i].Echo();
                t = spawned [i].type;
                Pickup(spawned [i]);
            }
            else if (spawned[i].at < -15)
            {
                Despawn(spawned[i].at);
            }
        }

        if (dir < 0)
        {
            if (exp.GetExperienceToLevel() > 1 || t == PickableItem.Type.LVL)
            {
                exp.AddXp();
            }
            else
            {
                if (ClimberStateManager.inTraining)
                {
                    exp.AddXp();
                }
                else
                {
                    Debug.Log("Cant give xp");
                }
            }

            SpawnRandom();
            //Debug.Log ("Shift spawns at "+offset);
        }
        else
        {
            exp.SubtractXp();
            //Debug.Log ("Shift spawns at 1");
            SpawnRandom(0, 1);
        }
    }
Ejemplo n.º 2
0
 public int ItemTypeToId(PickableItem.Type t)
 {
     for (int i = 0; i < types.Length; i++)
     {
         if (types[i] == t)
         {
             return(i);
         }
     }
     return(-1);
 }
Ejemplo n.º 3
0
    public int CountItems(PickableItem.Type t)
    {
        int result = 0;

        for (int i = 0; i < spawned.Count; i++)
        {
            if (spawned[i].type == t)
            {
                result++;
            }
        }
        return(result);
    }
Ejemplo n.º 4
0
 public void Spawn(PickableItem.Type t, Vector3 position, int at, bool force)
 {
     Spawn(ItemTypeToId(t), position, at, force);
 }
Ejemplo n.º 5
0
 public void Spawn(PickableItem.Type t)
 {
     Spawn(ItemTypeToId(t));
 }
Ejemplo n.º 6
0
 //=============================================
 //========= All the spawning methods ==========
 //=============================================
 public void SpawnForced(PickableItem.Type t, int pos, int at)
 {
     Spawn(ItemTypeToId(t), stairs.GetStepPosition(pos), at, true);
 }