Esempio n. 1
0
    public void ReadFromMap(Vector2 uv)
    {
        Vector2 pixelToInspect = new Vector2((uv.x * this.texture.width), (this.texture.height - (uv.y * this.texture.height)));

        Color32 c = this.texture.GetPixel((int)pixelToInspect.x, (int)pixelToInspect.y);

        Debug.Log("Color clicked: " + c);

        Continent continentClicked;

        try
        {
            continentClicked = MapColorToContinent [c];
        }
        catch (Exception e)
        {
            //Debug.Log ( "ReadFromMap::Couldn't read map at these coordinates. Returning Oceans." );

            Console.WriteLine(e);

            PlayerGameManager.lastContinentClicked = "Oceans";

            return;
        }

        //Debug.Log ( "Continent clicked: " + continentClicked.Name );

        PlayerGameManager.lastContinentClicked = continentClicked.Name;
        PlayerGameManager.OnLastContinentClickedChange();
    }
    private void FindComponents()
    {
        playerGameManager = GetComponent <PlayerGameManager> ();

        GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
        ConsoleLog.SLog("Player tag count: " + players.Length);
        foreach (GameObject p in players)
        {
            if (p.GetComponent <PlayerGameManager> () != null)
            {
                ConsoleLog.SLog("found real player");
            }
            if (p.GetComponent <RemoteCharacterController> () != null)
            {
                ConsoleLog.SLog("found remote player");
            }
        }

        rightArm = GameObject.FindGameObjectWithTag("RightArm");
        leftArm  = GameObject.FindGameObjectWithTag("LeftArm");
        gunEnd   = GameObject.FindGameObjectWithTag("GunEnd");
        gunRightArmIdleOffset = -gunEnd.transform.rotation.eulerAngles + rightArm.transform.rotation.eulerAngles;

        gunProp = GameObject.FindGameObjectWithTag("MyGun").GetComponent <GunProperties> ();
    }
 private void FindComponents()
 {
     gunprop           = GameObject.FindGameObjectWithTag("MyGun").GetComponent <GunProperties>();
     playerGameManager = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerGameManager> ();
     cardboardHead     = GameObject.FindGameObjectWithTag("PlayerHead").GetComponent <CardboardHead>();
     headPos           = GameObject.FindGameObjectWithTag("CameraPos").transform;
 }
    void OnTriggerEnter(Collider c)
    {
        if (c.GetComponent <PlayerGameManager> () != null)
        {
            //retrive old character data
            Vector3           pos = c.transform.position;
            Quaternion        rot = c.transform.rotation;
            PlayerGameManager playerGameManager = c.GetComponent <PlayerGameManager> ();
            float             health            = playerGameManager.health;
            int grenadeStore = playerGameManager.grenadeStore;

            //destroy old character
            playerGameManager = null;
            Destroy(c.gameObject);

            if (c.gameObject != null)
            {
                ConsoleLog.SLog("Why the f**k are you still exist!!??");
            }

            //trigger cardboardHead to find new character component
            CardboardHead cardboardHead = GameObject.FindGameObjectWithTag("PlayerHead").GetComponent <CardboardHead>();
            cardboardHead.isCharacterSync = false;

            //instantiate new character
            GameObject        newCharacter       = Instantiate(characterWithGunPrefab, pos, rot) as GameObject;
            PlayerGameManager newCharGameManager = newCharacter.GetComponent <PlayerGameManager> ();

            //set retrived data to new character
            newCharGameManager.health       = health;
            newCharGameManager.grenadeStore = grenadeStore;

            Destroy(gameObject);
        }
    }
    //-------------------------------------------------------------------------------

    void Start()
    {
        ConsoleLog.SLog("CardboardHead Start()");

        try {
            characterHead     = GameObject.FindGameObjectWithTag("CharacterHead").transform;
            player            = GameObject.FindGameObjectWithTag("Player").transform;
            playerGameManager = player.GetComponent <PlayerGameManager>();
            aimMask           = LayerMask.GetMask(raycastingMask);
            isCharacterSync   = true;
        } catch (System.Exception e) {
            ConsoleLog.SLog("Error in CardboardHead Start()\n" + e.Message);
        }

        if (characterHead != null && player != null)
        {
            syncHead = true;
        }
    }
 private void TakeDamage()
 {
     Collider[] colliders = Physics.OverlapSphere(detonatePosition, range);
     foreach (Collider c in colliders)
     {
         if (c.GetComponent <Rigidbody>() == null)
         {
             continue;
         }
         if (c.GetComponent <PlayerGameManager> () != null)
         {
             PlayerGameManager playerGameManager = c.GetComponent <PlayerGameManager> ();
             GameObject        player            = GameObject.FindGameObjectWithTag("Player");
             playerGameManager.TakeDamage(70.0f * ((range - Vector3.Distance(player.transform.position, detonatePosition)) / range));
         }
         if (c.GetComponent <GrenadeThrow> () != null && !c.GetComponent <GrenadeThrow> ().isDetonated)
         {
             c.GetComponent <GrenadeThrow> ().detonate();
         }
         if (c.GetComponent <Hit> () != null)
         {
             c.GetComponent <Hit> ().DestroyIt();
         }
         if (c.GetComponent <MilitaryBarrel> () != null)
         {
             c.GetComponent <MilitaryBarrel> ().DestroyIt();
         }
         if (c.GetComponent <OilBarrel> () != null && !c.GetComponent <OilBarrel> ().isDetonated)
         {
             c.GetComponent <OilBarrel> ().Detonate();
         }
         if (c.GetComponent <SlimeBarrel> () != null)
         {
             c.GetComponent <SlimeBarrel> ().DestroyIt();
         }
         c.GetComponent <Rigidbody>().AddExplosionForce(damage, detonatePosition, range, 0.0f, ForceMode.Impulse);
     }
     isDamage     = false;
     damage_timer = 0f;
     Destroy(explosionEffectObjectClone, 1.6f);
     Destroy(transform.parent.gameObject);
 }
Esempio n. 7
0
        public void UpdateCurrentPanelWarnings()
        {
            if (PlayerGameManager.GetInstance == null)
            {
                return;
            }
            if (currentPanel == null)
            {
                return;
            }

            currentPanel.foodControl.ShowWarning();
            currentPanel.coinControl.ShowWarning();
            currentPanel.troopControl.ShowWarning();
            currentPanel.villagerControl.ShowWarning();

            PlayerGameManager manager = PlayerGameManager.GetInstance;

            // COIN WARNING
            if (currentPanel.coinControl.myWarning != null)
            {
                if (manager.coinBehavior.warningDependentList.Find(x => x.showWarning) != null)
                {
                    List <WarningMessageClass> shownUpWarnings = new List <WarningMessageClass>();
                    shownUpWarnings.AddRange(manager.coinBehavior.warningDependentList.FindAll(x => x.showWarning));

                    currentPanel.coinControl.myWarning.SetupWarningDatas(shownUpWarnings);
                }
                else
                {
                    currentPanel.coinControl.myWarning.HideWarning();
                }
            }

            if (currentPanel.troopControl.myWarning != null)
            {
                // TROOPS WARNING
                if (manager.troopBehavior.warningDependentList.Find(x => x.showWarning) != null)
                {
                    List <WarningMessageClass> shownUpWarnings = new List <WarningMessageClass>();
                    shownUpWarnings.AddRange(manager.troopBehavior.warningDependentList.FindAll(x => x.showWarning));

                    currentPanel.troopControl.myWarning.SetupWarningDatas(shownUpWarnings);
                }
                else
                {
                    currentPanel.troopControl.myWarning.HideWarning();
                }
            }

            if (currentPanel.villagerControl.myWarning != null)
            {
                // POPULATION WARNING
                if (manager.populationBehavior.warningDependentList.Find(x => x.showWarning) != null)
                {
                    List <WarningMessageClass> shownUpWarnings = new List <WarningMessageClass>();
                    shownUpWarnings.AddRange(manager.populationBehavior.warningDependentList.FindAll(x => x.showWarning));

                    currentPanel.villagerControl.myWarning.SetupWarningDatas(shownUpWarnings);
                }
                else
                {
                    currentPanel.villagerControl.myWarning.HideWarning();
                }
            }

            if (currentPanel.foodControl.myWarning != null)
            {
                // FOOD WARNING
                if (manager.foodBehavior.warningDependentList.Find(x => x.showWarning) != null)
                {
                    List <WarningMessageClass> shownUpWarnings = new List <WarningMessageClass>();
                    shownUpWarnings.AddRange(manager.foodBehavior.warningDependentList.FindAll(x => x.showWarning));

                    currentPanel.foodControl.myWarning.SetupWarningDatas(shownUpWarnings);
                }
                else
                {
                    currentPanel.foodControl.myWarning.HideWarning();
                }
            }
        }
	//-------------------------------------------------------------------------------

	void Start() {
		ConsoleLog.SLog ("CardboardHead Start()");

		try {
			characterHead = GameObject.FindGameObjectWithTag ("CharacterHead").transform;
			player = GameObject.FindGameObjectWithTag ("Player").transform;
			playerGameManager = player.GetComponent<PlayerGameManager>();
			aimMask = LayerMask.GetMask (raycastingMask);
			isCharacterSync = true;
		} catch (System.Exception e){
			ConsoleLog.SLog ("Error in CardboardHead Start()\n" + e.Message);
		}

		if (characterHead != null && player != null) {
			syncHead = true;
		}
	}
	private void FindComponents(){
		playerGameManager = GetComponent<PlayerGameManager> ();

		GameObject[] players = GameObject.FindGameObjectsWithTag ("Player");
		ConsoleLog.SLog ("Player tag count: " + players.Length);
		foreach (GameObject p in players) {
			if (p.GetComponent<PlayerGameManager> () != null) {
				ConsoleLog.SLog ("found real player");
			}
			if (p.GetComponent<RemoteCharacterController> () != null) {
				ConsoleLog.SLog ("found remote player");
			}
		}

		rightArm = GameObject.FindGameObjectWithTag ("RightArm");
		leftArm = GameObject.FindGameObjectWithTag ("LeftArm");
		gunEnd = GameObject.FindGameObjectWithTag ("GunEnd");
		gunRightArmIdleOffset = - gunEnd.transform.rotation.eulerAngles + rightArm.transform.rotation.eulerAngles;

		gunProp = GameObject.FindGameObjectWithTag ("MyGun").GetComponent<GunProperties> ();
	}
	private void FindComponents() {
		gunprop = GameObject.FindGameObjectWithTag ("MyGun").GetComponent<GunProperties>();
		playerGameManager = GameObject.FindGameObjectWithTag ("Player").GetComponent<PlayerGameManager> ();
		cardboardHead = GameObject.FindGameObjectWithTag("PlayerHead").GetComponent<CardboardHead>();
		headPos = GameObject.FindGameObjectWithTag ("CameraPos").transform;
	}