Exemple #1
0
    public void assignScripts()
    {
        inventory = GameObject.FindGameObjectWithTag("Player").GetComponent <Inventory>();
        player    = GameObject.FindGameObjectWithTag("Player").GetComponent <AstronautMovement>();

        if (GameObject.FindGameObjectWithTag("IceGollem") != null)
        {
            iceGolem = GameObject.FindGameObjectWithTag("IceGollem").GetComponent <IceGolemScript>();
        }



        if (GameObject.FindGameObjectWithTag("Gollem") != null)
        {
            lavaGolem = GameObject.FindGameObjectWithTag("Gollem").GetComponent <FollowThePath>();
        }

        if (GameObject.FindGameObjectWithTag("MineralGollem") != null)
        {
            mineralGolem = GameObject.FindGameObjectWithTag("MineralGollem").GetComponent <MineralGolemScript>();
        }

        if (GameObject.FindGameObjectWithTag("FinalBoss") != null)
        {
            finalBoss = GameObject.FindGameObjectWithTag("FinalBoss").GetComponent <FinalBossMovement>();
        }
    }
Exemple #2
0
    public static void Save(AstronautMovement player, IceGolemScript iceGolem, FollowThePath lavaGolem, MineralGolemScript mineralGolem, FinalBossMovement finalBoss, List <GameObject> items)
    {
        BinaryFormatter formatter = new BinaryFormatter();

        string path = Application.persistentDataPath + "/player.save";

        FileStream stream = new FileStream(path, FileMode.Create);

        Data data = new Data(player, iceGolem, lavaGolem, mineralGolem, finalBoss, items);

        formatter.Serialize(stream, data);
        stream.Close();
    }
Exemple #3
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag.Equals("Player"))
        {
            if (gameObject.tag.Equals("Health"))
            {
                am = collision.gameObject.GetComponent <AstronautMovement>();
                am.increaseHealth(100);

                Destroy(gameObject);
            }
            else if (gameObject.tag.Equals("Oxygen"))
            {
                am = collision.gameObject.GetComponent <AstronautMovement>();
                am.increaseOxygen(50);

                Destroy(gameObject);
            }
            else if (gameObject.tag.Equals("DamageObject"))
            {
                am = collision.gameObject.GetComponent <AstronautMovement>();
                am.decreaseHealth(10);
            }
            else if (gameObject.tag.Equals("DecreaseOxygen"))
            {
                am = collision.gameObject.GetComponent <AstronautMovement>();
                am.decreaseOxygen(5);
            }
            else
            {
                counter = 0;

                for (int i = 0; i < inventory.slots.Length; i++)
                {
                    if (!inventory.isFull[i] && counter == 0)
                    {
                        inventory.isFull[i] = true;

                        inventory.slots[i].tag = item.tag;

                        Instantiate(item, inventory.slots[i].transform, false);
                        counter++;
                        Debug.Log("Picked up item");
                        Destroy(gameObject);
                        break;
                    }
                }
            }
        }
    }
Exemple #4
0
    void OnTriggerStay2D(Collider2D collision)
    {
        if (gameObject.tag.Equals("DamageObject"))
        {
            if (collision.gameObject.tag.Equals("Player"))
            {
                am = collision.gameObject.GetComponent <AstronautMovement>();
                am.decreaseHealth(10 * Time.deltaTime);
            }
        }

        if (gameObject.tag.Equals("DecreaseOxygen"))
        {
            if (collision.gameObject.tag.Equals("Player"))
            {
                am = collision.gameObject.GetComponent <AstronautMovement>();
                am.decreaseOxygen(10 * Time.deltaTime);
            }
        }
    }
Exemple #5
0
 private void Awake()
 {
     instance = this;
 }
Exemple #6
0
    public Data(AstronautMovement player, IceGolemScript iceGolem, FollowThePath lavaGolem, MineralGolemScript mineralGolem, FinalBossMovement finalBoss, List <GameObject> items)
    {
        health = player.health;
        oxygen = player.oxygen;


        if (items.Count > 0)
        {
            Debug.Log("Entered");
            tags = new int[items.Count];
            for (int i = 0; i < items.Count; i++)
            {
                if (items[i].tag != "Untagged")
                {
                    string tag = items[i].tag;
                    Debug.Log(tag);
                    tags[i] = int.Parse(tag);
                }
            }
        }

        if (iceGolem != null)
        {
            positionIceGolem = new float[3];



            positionIceGolem[0] = iceGolem.transform.position.x;
            positionIceGolem[1] = iceGolem.transform.position.y;
            positionIceGolem[2] = iceGolem.transform.position.z;

            iceGolemHealth = iceGolem.health;
        }
        else
        {
            iceGolemAlive = false;
        }

        if (lavaGolem != null)
        {
            lavaGolemHealth = lavaGolem.health;

            positionLavaGolem = new float[3];

            positionLavaGolem[0] = lavaGolem.transform.position.x;
            positionLavaGolem[1] = lavaGolem.transform.position.y;
            positionLavaGolem[2] = lavaGolem.transform.position.z;
        }
        else
        {
            lavaGolemAlive = false;
        }

        if (mineralGolem != null)
        {
            mineralGolemHealth = mineralGolem.health;

            positionMineralGolem = new float[3];

            positionMineralGolem[0] = mineralGolem.transform.position.x;
            positionMineralGolem[1] = mineralGolem.transform.position.y;
            positionMineralGolem[2] = mineralGolem.transform.position.z;
        }
        else
        {
            mineralGolemAlive = false;
        }

        if (finalBoss != null)
        {
            finalBossHealth = finalBoss.health;

            positionFinalBoss = new float[3];

            positionFinalBoss[0] = finalBoss.transform.position.x;
            positionFinalBoss[1] = finalBoss.transform.position.y;
            positionFinalBoss[2] = finalBoss.transform.position.z;
        }
        else
        {
            finalBossAlive = false;
        }



        positionPlayer = new float[3];



        positionPlayer[0] = player.transform.position.x;
        positionPlayer[1] = player.transform.position.y;
        positionPlayer[2] = player.transform.position.z;
    }
Exemple #7
0
 private void Save(AstronautMovement player, IceGolemScript iceGolem, FollowThePath lavaGolem, MineralGolemScript mineralGolem, FinalBossMovement finalBoss, List <GameObject> items)
 {
     SaveSystem.Save(player, iceGolem, lavaGolem, mineralGolem, finalBoss, items);
     hasSaved = true;
 }