Ejemplo n.º 1
0
    IEnumerator CreaGranja()
    {
        int[] createdPos = new int[2] {
            _row, _column
        };
//		soundControl.clip = createBuildingSound;
//		soundControl.Play();
        _ciudadanosDisponibles -= _buildings[1].PersonalRequerido;
        _presupuesto           -= _buildings[1].CostoConstruccion;
        PresupuestoT.text       = _presupuesto.ToString();
        Vector3 myPosition = selected.transform.position;

        yield return(StartCoroutine(ConstruyeTimer(_buildings[1].TiempoConstruccion)));

        GameObject   Granja = Instantiate(_buildings[1]._instance, new Vector3(myPosition.x, myPosition.y + 0.5f, myPosition.z), Quaternion.identity) as GameObject;
        ChargeScript cs     = Granja.GetComponent <ChargeScript>();

        cs.parentTransform = TimerArea.transform;
        cs.CM = this;
        _ciudadanosDisponibles += _buildings[1].PersonalRequerido;
        numeroGranjas          += 1;
        creations.Add(new BuildingsCreated()
        {
            PosX = createdPos[0], PosY = createdPos[1], _instance = Granja, BuildType = 1
        });
    }
Ejemplo n.º 2
0
    void Start()
    {
        manager = GameObject.Find("Main Camera").GetComponent <NPCManager>();

        characterController = GetComponent <CharacterController>();
        //weaponText = canvas.GetComponentInChildren<Text>();

        shield = gameObject.GetComponentInChildren <ShieldScript>();
        laser  = gameObject.GetComponentInChildren <LaserScript>();
        charge = gameObject.GetComponentInChildren <ChargeScript>();
        bomb   = gameObject.GetComponentInChildren <BombScript>();

        laserSound = gameObject.GetComponent <AudioSource>();

        cameraScript = GameObject.Find("Main Camera").GetComponent <CameraFollow>();

        futurePosition = GetComponentInChildren <FuturePositionScript>().transform;

        if (Input.GetJoystickNames().Length > 0)
        {
            isControllerConnected = true;
        }

        transform.position = spawnPoint;

        if (GameObject.Find("PlayerUI"))
        {
            ui = GameObject.Find("PlayerUI").GetComponent <PlayerUI>();
        }
    }
Ejemplo n.º 3
0
	void Awake()
	{
		// Gets all the reference scripts needed
		mainDrinkScriptRef = GameObject.Find("Drinks").GetComponent<MainDrinksScript>();
		slider = GameObject.Find("Slider");
		mySliderRef = slider.GetComponent<UISlider>();
		myChargeRef = slider.GetComponent<ChargeScript>();
	
	}
Ejemplo n.º 4
0
    IEnumerator CreaGranja()
    {
        int[] createdPos = new int[2] {
            _row, _column
        };
        //		soundControl.clip = createBuildingSound;
        //		soundControl.Play();
        PresupuestoT.text = "100";
        Vector3 myPosition = selected.transform.position;

        yield return(StartCoroutine(ConstruyeTimer(4.0f)));

        tutScreens [19].SetActive(true);
        GameObject Granja = Instantiate(GranjaInstance, new Vector3(myPosition.x, myPosition.y + 0.5f, myPosition.z), Quaternion.identity) as GameObject;

        granjaGlow = Instantiate(glowbObj2, new Vector3(myPosition.x, myPosition.y + 0.5f, myPosition.z), Quaternion.identity) as GameObject;
        granjaGlow.SetActive(false);
        ChargeScript cs = Granja.GetComponent <ChargeScript>();

        cs.parentTransform = TimerArea.transform;
        cs.TM    = this;
        canTouch = false;
    }
Ejemplo n.º 5
0
    void OnTriggerEnter(Collider col)
    {
        //COLLECT CHARGES
        if (col.gameObject.tag == "Charge")
        {
            ChargeScript chargeScript = col.GetComponent <ChargeScript>();
            //Makes sure that the charge isn't collected twice on accident
            if (chargeScript.isCollected == false)
            {
                chargeScript.isCollected = true;
                if (ValueHolder.music)
                {
                    soundEffects[0].Play();
                }

                Destroy(col.gameObject);
                charges++;
                //Update the charge bar to reflect the new charge.
                chargeBarDisplay.GetComponent <ChargeBarDisplay>().UpdateText();
            }
        }

        //KNOCK THE BUCKET OFF
        if (col.gameObject.tag == "Bucket Trigger")
        {
            bucket.GetComponent <BucketScript>().activate();
        }

        //TELEPORT VIA THE PORTALS
        if (col.gameObject.tag == "Portal")
        {
            soundEffects[1].Play();
            PortalScript portal = col.gameObject.GetComponent <PortalScript>();
            gameObject.GetComponent <Transform>().position = new Vector3(portal.targetX, portal.targetY, portal.targetZ);
        }

        //ACTIVATE A CHECKPOINT
        if (col.gameObject.tag == "Checkpoint")
        {
            soundEffects[1].Play();

            Checkpoint ch = col.gameObject.GetComponent <Checkpoint>();

            if (ch.number > ValueHolder.checkpointNumber)
            {
                ValueHolder.checkpointNumber = ch.number;
                Debug.Log("CHECKPOINT " + ValueHolder.checkpointNumber);
            }

            for (int i = 0; i <= ch.number; i++)
            //for every checkpoint less than or equal to the checkpoint just passed through, light it up
            {
                GameObject check = checkpoints[i];
                check.GetComponent <Checkpoint>().lightOn();
            }

            //Update the charge bar to reflect the new level - a different number of charges is required to time travel
            chargeBarDisplay.GetComponent <ChargeBarDisplay>().UpdateText();
        }

        //COLLECT RUM
        if (col.gameObject.tag == "Rum")
        {
            soundEffects[3].Play();
            Destroy(col.gameObject);
            if (health < 3)
            {
                gameObject.GetComponentInParent <PlayerScript>().health++;
                healthDisplayer.GetComponent <HealthBarDisplay>().UpdateText();
            }
        }
    }
Ejemplo n.º 6
0
//	public void SetNextDisaster()
//	{
//		_link.CallDisaster ();
//	}

    void LoadIfExists()
    {
        DataStorage _ds = GameObject.FindObjectOfType <DataStorage> ();

        if (_ds != null)
        {
//			if (!_ds._usingEvents) {
//				Debug.Log ("No invocar eventos");
//				_link.CancelAllNotification();
//			} else
//			{
//				Debug.Log ("Invocar Eventos");
//				_link.CallDisaster ();
//			}
            if (_ds._dataStored != null)
            {
                StatsData          sd = _ds._dataStored;
                BuildingsCreated[] bc = sd._totalBuildings;
                _poblacion           = sd.aldeanosTotal;
                _presupuesto         = sd.dinero;
                _comida              = sd.comida;
                _ciudadanosSinComida = sd.aldeanosHambrientos;
//				_ciudadanosEnfermos = sd.aldeanosEnfermos;
                Hambrientos.text = _ciudadanosSinComida.ToString();
//				EnfermosT.text = _ciudadanosEnfermos.ToString ();;
                for (int i = 0; i < _poblacion; i++)
                {
                    HumanClass habitante = new HumanClass();
                    habitante.CM = this;
                    habitantes.Add(habitante);
                }
//				for (int i = 0; i < _ciudadanosEnfermos; i++)
//				{
//					habitantes [i].TieneSalud = false;
//				}
                for (int x = 0; x < bc.Count(); x++)
                {
                    GameObject parent     = MatrixPro [bc [x].PosX].ObjectRow [bc [x].PosY];
                    Vector3    myPosition = parent.transform.position;
                    GameObject building   = Instantiate(_buildings [bc [x].BuildType]._instance, new Vector3(myPosition.x, myPosition.y + 0.5f, myPosition.z), Quaternion.identity) as GameObject;
                    AreaMatrix [bc [x].PosX, bc [x].PosY] = true;
                    switch (bc [x].BuildType)
                    {
                    case 0:
//						numeroHospitales++;
                        break;

                    case 1:
                        numeroGranjas++;
                        break;

                    case 2:
                        break;

                    case 3:
                        numeroViviendas++;
                        break;

                    case 4:
                        numeroBancos++;
                        break;

                    case 5:
                        numeroBancos++;
                        break;
                    }
                    if (bc [x].BuildType != 3)
                    {
                        ChargeScript cs = building.GetComponent <ChargeScript> ();
                        cs.parentTransform = TimerArea.transform;
                        cs.CM = this;
                    }
                }
            }
            else
            {
                _poblacion       = 100;
                _presupuesto     = 1000;
                _comida          = 1000;
                Hambrientos.text = "0";
//				EnfermosT.text = "0";
                for (int i = 0; i < _poblacion; i++)
                {
                    HumanClass habitante = new HumanClass();
                    habitante.CM = this;
                    habitantes.Add(habitante);
                }
            }
            Destroy(_ds.gameObject);
        }
        else
        {
            _poblacion       = 100;
            _presupuesto     = 1000;
            _comida          = 1000;
            Hambrientos.text = "0";
            //		EnfermosT.text = "0";
            for (int i = 0; i < _poblacion; i++)
            {
                HumanClass habitante = new HumanClass();
                habitante.CM = this;
                habitantes.Add(habitante);
            }
        }
    }
Ejemplo n.º 7
0
    void Start()
    {
        manager = GameObject.Find("Main Camera").GetComponent<NPCManager>();

        characterController = GetComponent<CharacterController>();
        //weaponText = canvas.GetComponentInChildren<Text>();

        shield = gameObject.GetComponentInChildren<ShieldScript>();
        laser = gameObject.GetComponentInChildren<LaserScript>();
        charge = gameObject.GetComponentInChildren<ChargeScript>();
        bomb = gameObject.GetComponentInChildren<BombScript>();

        laserSound = gameObject.GetComponent<AudioSource>();

        cameraScript = GameObject.Find("Main Camera").GetComponent<CameraFollow>();

        futurePosition = GetComponentInChildren<FuturePositionScript>().transform;

        if (Input.GetJoystickNames().Length > 0)
        {
            isControllerConnected = true;
        }

        transform.position = spawnPoint;

        if (GameObject.Find("PlayerUI"))
        {
            ui = GameObject.Find("PlayerUI").GetComponent<PlayerUI>();
        }
    }