Example #1
0
 public void Input()
 {
     foreach (string line in rawInput)
     {
         string[] split = line.Split(' ');
         Debug.Log(gameObject + line + split.Length.ToString());
         if (split.Length == 0)
         {
             continue;
         }
         if (split[0].Equals("STAT"))
         {
             stats.Add(split[1], new FloatStat(split[1], float.Parse(split[2])));
         }
         else if (split[0].Equals("EFFECT"))
         {
             FloatStat dfl = new FloatStat(split[1]);
             impactEffects[split[1]] = new FSQI(dfl,
                                                split[2],
                                                float.Parse(split[3]),
                                                float.Parse(split[4]),
                                                int.Parse(split[5])
                                                );
         }
     }
 }
Example #2
0
    public void applyPowerup(FloatStat stat, string powName, float value = 1.0f, float duration = -0.1f, int mode = 0)
    {
        float time = Time.time + duration;
        int   timePeriod = time_period(time);
        FSQI  powerup, template, existing;

        powerup  = new FSQI(stat, powName, value, time);
        template = new FSQI(stat, powName);
        Debug.Log(stat.getName() + mode);
        if (directAccess.ContainsKey(template))
        {
            existing = directAccess[template];
            queue[time_period(existing.time)].Remove(existing);
            directAccess.Remove(template);
        }
        else
        {
            queue[timePeriod] = new List <FSQI>();
        }
        if (mode == 1)
        {
            stat.ChangeWithFactor(powName, value); return;
        }
        stat.setFactor(powName, value);

        if (duration > 0)
        {
            queue[timePeriod].Add(powerup);
            directAccess[template] = powerup;
        }
    }
Example #3
0
 public void applyPowerup(FSQI fSQI)
 {
     applyPowerup(fSQI.stat, fSQI.modifier, fSQI.value, fSQI.time, fSQI.mode);
 }
Example #4
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        GameObject   other   = collision.gameObject;
        EntityScript otherES = other.GetComponent <EntityScript>();

        //Debug.Log(gameObject + "-->" + other);
        if (gameObject.CompareTag(GameDefaults.Projectile()) && (other.CompareTag(GameDefaults.Obstruction())))
        {
            Destroy(gameObject);
            return;
        }
        if (gameObject.CompareTag(GameDefaults.Projectile()) && other.CompareTag(GameDefaults.Projectile()))
        {
            return;
        }
        if (gameObject.CompareTag(GameDefaults.Powerup()) && !other.CompareTag(GameDefaults.Player()))
        {
            return;
        }
        if (other.CompareTag(GameDefaults.Powerup()))
        {
            return;
        }
        if (other.CompareTag(GameDefaults.Obstruction()))
        {
            return;
        }

        if (otherES != null)
        {
            if (parent != null)
            {
                if (other.gameObject.CompareTag(parent.tag) || otherES.parent != null && otherES.parent.gameObject.CompareTag(gameObject.tag))
                {
                    return;
                }
            }

            foreach (string effect in impactEffects.Keys)
            {
                //Debug.Log(effect);
                if (effect.Equals("damage"))
                {
                    if (gameObject.CompareTag(GameDefaults.Enemy()))
                    {
                        if (!gameObject.GetComponent <AiScriptBase>().isDangerous())
                        {
                            continue;
                        }
                        else
                        {
                            gameObject.GetComponent <AiScriptBase>().setDanger(false);
                        }
                    }
                    if (!otherES.stats.ContainsKey("health"))
                    {
                        continue;
                    }

                    float x = impactEffects["damage"].value;
                    if (otherES.stats.ContainsKey("armor"))
                    {
                        FloatStat FSA = otherES.stats["armor"];
                        if (FSA.getCompoundValue() >= 100)
                        {
                            x = 0;
                        }
                        else
                        {
                            x = Mathf.Max(x - FSA.getCompoundValue(), 1f);
                        }
                    }
                    FloatStat FSH = otherES.stats["health"];
                    otherES.controller.damage((int)x);
                    FSH.ChangeWithFactor("baseValue", 0 - x);
                    FSH = new FloatStat("health", Mathf.RoundToInt(FSH.getCompoundValue()));
                }
                else if (effect.Equals("healthBoost"))
                {
                    if (!otherES.stats.ContainsKey("health"))
                    {
                        continue;
                    }

                    float     x   = impactEffects["health"].value;
                    FloatStat FSH = otherES.stats["health"];

                    FSH.ChangeWithFactor("baseValue", x);
                }
                else
                {
                    FSQI effectData = impactEffects[effect];
                    Debug.Log(otherES.stats.ContainsKey(effect).ToString() + effect);
                    if (!otherES.stats.ContainsKey(effect))
                    {
                        continue;
                    }
                    effectData.ApplyTo(otherES);
                }
            }
        }
        if (gameObject.CompareTag(GameDefaults.Powerup()) && other.CompareTag(GameDefaults.Player()))
        {
            Destroy(gameObject);
            return;
        }
        //Stari kod
        if (true) //Unity ima ugrađene tagove i layere, zasto si stvarao svoje?
        {
            //Projectile collisions
            if (gameObject.CompareTag(GameDefaults.Projectile()))
            {
                //Obstruction
                if (other.CompareTag(GameDefaults.Obstruction()))
                {
                    Destroy(gameObject);
                    return;
                }
                if (parent != null && !parent.CompareTag(other.gameObject.tag))
                {
                    controller.OnTriggerEnter2D(collision);
                    GameObject.Destroy(gameObject);

                    // Wake up any script that is attached to the enemy + navmesh
                    var otherChaser = other.GetComponent <AiScriptBase>();
                    if (otherChaser != null && !otherChaser.enabled)
                    {
                        otherChaser.enabled = true;
                        other.GetComponent <NavMeshAgent>().enabled = true;
                    }
                }
            }
            //Enemy coll
            else if (gameObject.CompareTag(GameDefaults.Enemy()))
            {
                //Obstruction
                if (other.CompareTag(GameDefaults.Obstruction()))
                {
                    //Zid
                }
                //Enemy
                else if (other.CompareTag(GameDefaults.Enemy()))
                {
                    //var es = other.gameObject.GetComponent<EntityScript>();
                }
                //Player
                else if (other.gameObject.CompareTag(GameDefaults.Player()))
                {
                    if (controller != null && collision != null)
                    {
                        controller.OnTriggerEnter2D(collision);
                    }
                }
            }
            else if (gameObject.CompareTag(GameDefaults.Player()))
            {
                if (other.gameObject.CompareTag(GameDefaults.LevelExit()))
                {
                    if (controller != null && collision != null)
                    {
                        controller.OnTriggerEnter2D(collision);
                    }
                }
            }
        }
    }