Beispiel #1
0
 void OnMouseDown()
 {
     if (tmpGameObject != null)
     {
         if (tmpGameObject.name == "Farm" || tmpGameObject.name == "Flower" || tmpGameObject.name == "FlowerBox" ||
             tmpGameObject.name == "SwimmingHole")
         {
             GameObject      scoreController = GameObject.Find("ScoreController") as GameObject;
             ScoreController other           = scoreController.GetComponent("ScoreController") as ScoreController;
             other.IncreaseScore(100);
         }
         else
         {
             if (tmpGameObject.name == "SeaHa" || tmpGameObject.name == "NatureHa" ||
                 tmpGameObject.name == "ElectricHa")
             {
                 GameObject      scoreController = GameObject.Find("ScoreController") as GameObject;
                 ScoreController other           = scoreController.GetComponent("ScoreController") as ScoreController;
                 MoveBuilding    tmpMoveBuilding = tmpGameObject.GetComponent("MoveBuilding") as MoveBuilding;
                 if (tmpMoveBuilding.dragonAnimationBelong2Building != null)
                 {
                     print("AAA");
                     print(tmpMoveBuilding.dragonAnimationBelong2Building.name);
                     if (tmpMoveBuilding.dragonAnimationBelong2Building.name == "DarkAnimation(Clone)")
                     {
                         other.IncreaseScore(100 + 750);
                     }
                     else if (tmpMoveBuilding.dragonAnimationBelong2Building.name == "RedAnimation(Clone)")
                     {
                         other.IncreaseScore(100 + 900);
                     }
                     else if (tmpMoveBuilding.dragonAnimationBelong2Building.name == "YelllowAnimation(Clone)")
                     {
                         other.IncreaseScore(100 + 1500);
                     }
                     Destroy(tmpMoveBuilding.dragonAnimationBelong2Building);
                 }
                 else
                 {
                     other.IncreaseScore(100);
                 }
             }
         }
         if (tmpGameObject != null)
         {
             Destroy(tmpGameObject);
         }
     }
     if (gameObject != null)
     {
         Destroy(gameObject);
     }
 }
Beispiel #2
0
	void OnMouseDown ()
	{
		if (tmpGameObject != null && tmpGameObject.tag=="Building") {
			MoveBuilding moveBuildingScript = tmpGameObject.GetComponent ("MoveBuilding") as MoveBuilding;
			moveBuildingScript.canMoveAgain=true;
			moveBuildingScript.isMoving=true;
			moveBuildingScript.Ground.SetActive(true);
			moveBuildingScript.beforeMovingPosition=moveBuildingScript.transform.position;
			moveBuildingScript.canBuild=true;
		} else {

		}
		Destroy (gameObject);
	}
Beispiel #3
0
	// Use this for initialization
	void Start () {
		movebuilding = GetComponent<MoveBuilding> ();
		destroybuilding = GetComponent<DestroyBuilding> ();
		moveBuild = false;
		destroyBuil = false;
	}
    void OnMouseDown()
    {
        if (canBuild == false)
        {
            Destroy(gameObject);
            clone = Instantiate(cannotBuidWindow, cannotBuidWindow.transform.position, Quaternion.identity) as GameObject;
        }
        if (canBuild == true)
        {
            bool            checkGold       = false;
            GameObject      scoreController = GameObject.Find("ScoreController") as GameObject;
            ScoreController other           = scoreController.GetComponent("ScoreController") as ScoreController;

            MoveBuilding tmpMoveBuilding = BuildingDetect.GetComponent("MoveBuilding") as MoveBuilding;
            if (tmpMoveBuilding.numberOfDragon == 1)
            {
                clone = Instantiate(numberDragonWindow, cannotBuidWindow.transform.position, Quaternion.identity) as GameObject;
                Destroy(gameObject);
                return;
            }


            if (gameObject.name == "SeaDragon")
            {
                checkGold = other.CheckGoldIsOK(1500);
                if (checkGold == true)
                {
                    other.DecreaseScore(1500);
                    other.IncreaseDragon(1);
                }
                else
                {
                    Debug.Log("Khong du tien");
                    Destroy(gameObject);
                    clone = Instantiate(noMoneyWindow, noMoneyWindow.transform.position, Quaternion.identity) as GameObject;
                }
            }
            else
            if (gameObject.name == "NatureDragon")
            {
                checkGold = other.CheckGoldIsOK(1800);
                if (checkGold == true)
                {
                    other.DecreaseScore(1800);
                    other.IncreaseDragon(1);
                }
                else
                {
                    Debug.Log("Khong du tien");
                    Destroy(gameObject);
                    clone = Instantiate(noMoneyWindow, noMoneyWindow.transform.position, Quaternion.identity) as GameObject;
                }
            }
            else
            if (gameObject.name == "ElectricDragon")
            {
                checkGold = other.CheckGoldIsOK(3000);
                if (checkGold == true)
                {
                    other.DecreaseScore(3000);
                    other.IncreaseDragon(1);
                }
                else
                {
                    Debug.Log("Khong du tien");
                    Destroy(gameObject);
                    clone = Instantiate(noMoneyWindow, cannotBuidWindow.transform.position, Quaternion.identity) as GameObject;
                }
            }
            if (checkGold == true)
            {
                tmpMoveBuilding.numberOfDragon = tmpMoveBuilding.numberOfDragon + 1;
                Vector3 tmp = gameObject.transform.position;
                tmp.z = 10;
                Destroy(gameObject);
                clone = Instantiate(animationDark, tmp, Quaternion.identity) as GameObject;

                //MoveBuilding tmpMoveBuilding = BuildingDetect.GetComponent ("MoveBuilding") as MoveBuilding;
                tmpMoveBuilding.dragonAnimationBelong2Building = clone;
                tmpMoveBuilding.offsetDragonVSHabitat          = tmpMoveBuilding.dragonAnimationBelong2Building.transform.position - BuildingDetect.transform.position;
            }
        }
    }