Exemple #1
0
    public void DispenseObject(GameObject dispensable, Vector2 location, Vector2 direction, float speed = 0.2f, string[] input = null, string type = "projectile")
    {
        GameObject   x = Instantiate(dispensable);
        EntityScript y = x.AddComponent <EntityScript>();

        y.Init(type, location, direction, speed, gameObject);
        if (input != null)
        {
            y.rawInput.AddRange(input);
        }
        if (type == "projectile")
        {
            float dmg = stats["ranged"].getCompoundValue();
            y.rawInput.Add("EFFECT damage irrelevant " + dmg.ToString() + " 0 1");
        }
        y.Input();
        Debug.Log(speed);
        y.Init(type, location, direction, speed, gameObject);
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        Vector2 v;

        counter++;
        if (counter == DispensingFrames)
        {
            GameObject x = Instantiate(dispensable);
            v = new Vector2(Random.Range(-1.0f, 1.0f), Random.Range(-1.0f, 1.0f));
            EntityScript ES = x.GetComponent <EntityScript>();
            if (ES == null)
            {
                ES = x.AddComponent <EntityScript>();
                ES.Init("projectile", gameObject.transform.position, v.normalized, 20f, gameObject);
            }
            counter++;
            counter %= 4;
        }
    }