Example #1
0
    public void addToPowerSet(PowerPickups powers)
    {
        bool found = false;

        foreach (PowerPickups p in activePowers)
        {
            if (p.getName().Equals(powers.getName()))
            {
                found = true;
            }
        }
        if (!found)
        {
            if (powers.getName().Equals("Circular"))
            {
                Debug.Log("Circular");
                powers.powerScript = GameObject.Find("Player").GetComponent <Echo> ();
            }
            else if (powers.getName().Equals("Flashlight"))
            {
                Debug.Log("Flashlight");
                powers.powerScript = GameObject.Find("Player").GetComponent <Flashlight> ();
            }
            else if (powers.getName().Equals("Ray"))
            {
                Debug.Log("Ray");
                powers.powerScript = GameObject.Find("Player").GetComponent <Ray> ();
            }
            else if (powers.getName().Equals("Atium"))
            {
                Debug.Log("Atium");
                powers.powerScript = GameObject.Find("Player").GetComponent <Atium> ();
            }
            else
            {
                Debug.Log("Not changing powerScript");
            }
            activePowers.Add(powers);
            powerManager.addPower(powers.powerScript);
        }
    }
Example #2
0
    public override bool Equals(object other)
    {
        PowerPickups otherPickup = (PowerPickups)other;

        return(getName().Equals(otherPickup.getName()));
    }
Example #3
0
    /*
     * void OnGUI()
     * {
     *  int y = 1;
     *  Rect r;
     *  foreach (PowerPickups p in activePowers) {
     *      r = new Rect(0, Screen.height - 20 * y, 100, 20);
     *      GUI.Box(r, p.getName());
     *      r = new Rect(100, Screen.height - 20 * y, 100, 20);
     *      if (p.powerScript != null)
     *      {
     *          GUI.Box(r, p.powerScript.getName());
     *      }
     *      else {
     *          GUI.Box(r, "NULL");
     *      }
     *      y++;
     *  }
     *  r = new Rect(0, Screen.height - 20 * y, 150, 20);
     *  GUI.Box(r, "Power List Inventory");
     * }
     */
    //Loads the temporary inventory into inventory
    void Start()
    {
        //Reload non-power inventory
        inventoryList.Clear();
        inventoryList = tempInventory.inventoryPickup;
        //Reload power inventory
        Debug.Log("--------------------------------------------------------");
        powerManager = GameObject.Find("Player").GetComponent <Powers>();
        clearPowerSet();
        HashSet <PowerPickups> oldInventory = tempInventory.powerPickup;
        HashSet <PowerPickups> newInventory = new HashSet <PowerPickups>();

        foreach (PowerPickups p in oldInventory)
        {
            if (p.getName().Equals("Circular"))
            {
                //PowerPickups circular = GameObject.Find("Circular");
                newInventory.Add(new PowerPickups("Circular", GameObject.Find("Player").GetComponent <Echo> (), circularAudioLog, circularText));
            }
            else if (p.getName().Equals("Movement"))
            {
                newInventory.Add(new PowerPickups("Movement", GameObject.Find("Player").GetComponent <Movement> (), movementAudioLog, movementText));
            }
            else if (p.getName().Equals("Flashlight"))
            {
                newInventory.Add(new PowerPickups("Flashlight", GameObject.Find("Player").GetComponent <Flashlight> (), flashlightAudioLog, flashlightText));
            }
            else if (p.getName().Equals("Ray"))
            {
                newInventory.Add(new PowerPickups("Ray", GameObject.Find("Player").GetComponent <Ray> (), rayAudioLog, rayText));
            }
            else if (p.getName().Equals("Atium"))
            {
                newInventory.Add(new PowerPickups("Atium", GameObject.Find("Player").GetComponent <Atium> (), atiumAudioLog, atiumText));
            }
            else
            {
                Debug.Log("Temp Inventory Loading Error");
            }
        }
        Debug.Log("Starting Scene: (" + newInventory.Count + ", " + tempInventory.powerPickup.Count + ")");
        mergePowerSet(newInventory);
        IPower movementScript = GameObject.Find("Player").GetComponent <Movement>();

        Debug.Log("Starting Inventory");
        Debug.Log("Movement scripts name : " + movementScript.getName());
        PowerPickups movementPickup = new PowerPickups("Movement", movementScript, movementAudioLog, movementText);

        addToPowerSet(movementPickup);


        Debug.Log("loaded level on player end!");
        if (Title.g_save != null)
        {
            float x = Title.g_save.x;
            float y = Title.g_save.y;
            LinkedList <string> powers = Title.g_save.powers;
            Title.g_save = null;
            Transform t = GetComponent <Transform>();
            t.position = new Vector2(x, y);
            Inventory i = GameObject.Find("Player").GetComponent <Inventory>();
            foreach (string p in powers)
            {
                i.addToPowerSet(new PowerPickups(p, GameObject.Find("Player").GetComponent(p) as IPower, null, null));
                GameObject pickup = GameObject.Find(p);
                if (pickup != null)
                {
                    Destroy(pickup);
                }
            }
        }
    }