public int SetDestroyedCube(GameObject toDestroyingCube)
 {
     switch (toDestroyingCube.ToString())
     {
         case "DirtCube(Clone) (UnityEngine.GameObject)":
             destroyedItem = 0;
             break;
         case "StoneCube(Clone) (UnityEngine.GameObject)":
             destroyedItem = 1;
             break;
         case "Wooden_PlanksCube(Clone) (UnityEngine.GameObject)":
             destroyedItem = 2;
             break;
         case "Copple_stone(Clone) (UnityEngine.GameObject)":
             destroyedItem = 3;
             break;
         case "Gravel(Clone) (UnityEngine.GameObject)":
             destroyedItem = 4;
             break;
         case "Sand(Clone) (UnityEngine.GameObject)":
             destroyedItem = 5;
             break;
         case "Bedrock(Clone) (UnityEngine.GameObject)":
             destroyedItem = 6;
             break;
         case "Obsidian(Clone) (UnityEngine.GameObject)":
             destroyedItem = 7;
             break;
         case "Brick(Clone) (UnityEngine.GameObject)":
             destroyedItem = 8;
             break;
     }
     //print (destroyedItem);
     return destroyedItem;
 }
 void Check(GameObject obj)
 {
     //check gameObject's number
     if(obj == objectList[count] && !bIsSolved)
     {
         Debug.Log ("Match! Obj: " + obj.ToString() + " Count: " + count + " ObjList: " + objectList[count].ToString());
         Debug.Log ("Count List: " + objectList.Count);
         if(count == objectList.Count - 1)
         {
             Open ();
             bIsSolved = true;
             this.gameObject.renderer.material.color = Color.green;
         }
         count++;
     }
     else
     {
         count = 0;
         foreach(GameObject item in objectList)
         {
             objectList[count].SendMessage("Reset");
             count++;
         }
         count = 0;
         this.renderer.material.color = Color.red;
         Debug.Log ("Reset! Count: " + count);
     }
 }
 // Use this for initialization
 void Start()
 {
     gl = (GameLogic)FindObjectOfType(typeof(GameLogic));
     ft = (FractalTexture)FindObjectOfType(typeof(FractalTexture));
     pl = (Player)FindObjectOfType(typeof(Player));
     whiteNoise = GameObject.Find("WhiteNoise");
     Debug.Log("White Noise: " + whiteNoise.ToString());
 }
Example #4
0
	void Start() {
		currentScene = Object.Instantiate (scenePrefabs[0]);
		metricController = GetComponent<MetricController>();
		totalTimeSpentDrinkingCoffee = 0.0f;
		Debug.Log (currentScene.ToString ());
		fader = c.GetComponent<Fade> ();
		IsGameOver = false;
		fader.FadeIn ();
	}
 public void setDrone(int role, GameObject obj)
 {
     switch(role)
     {
         case 0: droneLeft = obj; break;
         case 1: droneRight = obj; break;
         case 2: droneBack = obj; break;
         default: Debug.Log("Error : unknown role for drone "+obj.ToString()); break;
     }
 }
Example #6
0
 static GameObject GetCache(GameObject G)
 {
     if (G == null)
         throw new System.Exception("Constraint Spawner null object requested");
     if (Cache == null) Cache = new Dictionary<GameObject, GameObject>();
     if (!Cache.ContainsKey(G))
         Cache[G] = (GameObject)Instantiate(G, new Vector3(0, -100, 0), new Quaternion());
     if (!Cache.ContainsKey(G))
         throw new System.Exception(G.ToString() + " Constraint spawner could not spawn blueprint");
     return Cache[G];
 }
Example #7
0
    void LoadMagePrefs()
    {
        selectedCharacter = Mage;
        Debug.Log(selectedCharacter.ToString());

        if (GameObject.Find("Picture"))
        {
            ImageOff.enabled = true;
            GameObject SelectImage = GameObject.Find("CharacterPicture");
            Image MagePicture = SelectImage.GetComponent<Image>();
            MagePicture.sprite = MagePic;
        }

        if (GameObject.Find("Atributos"))
        {
            //Procura os gameobjects
            GameObject WriteHP = GameObject.Find("HPText");
            GameObject WriteMP = GameObject.Find("MPText");
            GameObject WriteSTR = GameObject.Find("STRText");
            GameObject WriteVIT = GameObject.Find("VITText");
            GameObject WriteDEX = GameObject.Find("DEXText");
            GameObject WriteINT = GameObject.Find("INTText");

            //Escreve nas labels.
            Text textHP = WriteHP.GetComponent<Text>();
            textHP.text = "100".ToString();
            Text textMP = WriteMP.GetComponent<Text>();
            textMP.text = "150".ToString();
            Text textSTR = WriteSTR.GetComponent<Text>();
            textSTR.text = "7 *1.8".ToString();
            Text textVIT = WriteVIT.GetComponent<Text>();
            textVIT.text = "5 *1.7".ToString();
            Text textDEX = WriteDEX.GetComponent<Text>();
            textDEX.text = "5 * 1.7".ToString();
            Text textINT = WriteINT.GetComponent<Text>();
            textINT.text = "12 *1.5".ToString();

        }

        if (GameObject.Find("Skills"))
        {
            GameObject WriteSkill1 = GameObject.Find("Skill1Text");
            GameObject WriteSkill2 = GameObject.Find("Skill2Text");
            GameObject WriteSkill3 = GameObject.Find("Skill3Text");

            Text textSkill1 = WriteSkill1.GetComponent<Text>();
            textSkill1.text = "Fireball".ToString();
            Text textSkill2 = WriteSkill2.GetComponent<Text>();
            textSkill2.text = "Throw Stone".ToString();
            Text textSkill3 = WriteSkill3.GetComponent<Text>();
            textSkill3.text = "Water Blast".ToString();
        }
    }
Example #8
0
 void Generate()
 {
     if(numLeft > 0) {
         current = GameObject.Instantiate(blockProto, Vector3.zero, Quaternion.identity) as GameObject;
         Debug.Log (current.ToString());
         Debug.Log (current.GetType ().ToString());
         current.transform.SetParent (gameObject.transform);
         current.transform.localPosition = new Vector3(0.6f, 0, 0);
         current.transform.localScale = new Vector3(1, 1, 1);
         current.GetComponent<ProgBlock>().onPickup += OnPickup;
     }
 }
Example #9
0
 public Pool(GameObject obj, GameObject parent, int size)
 {
     index = 0;
     GameObject container = new GameObject("Pool"+obj.ToString());
     container.transform.SetParent(parent.transform);
     for (int i = 0; i < size; i++)
     {
         GameObject instance = GameObject.Instantiate(obj);
         instance.transform.parent = container.transform;
         instance.SetActive(false);
         objects.Add(instance);
     }
 }
 public override int Assign(GameObject entity)
 {
     if (entityMap [0] == null) {
         FormationLeader = entity;
         entityMap [0] = entity;
         return 0;
     } else if (entityMap [1] == null) {
         entityMap [1] = entity;
         return 1;
     } else {
         throw (new UnityException ("Tried to Assign entity " + entity.ToString () + " to a full formation."));
     }
 }
    public void onSelection(GameObject selected)
    {
        Debug.Log (selected.ToString());
        if (buttons != null) {
            foreach(Button b in buttons){
                b.image.sprite = offSprite;
                //Debug.Log(b.ToString);
            }
            Image i = selected.GetComponent<Image>();
            i.sprite = onSprite;

        }
    }
Example #12
0
        /// <summary>
        /// Checks to see if an entity is tagged with a specified tag
        /// </summary>
        /// <param name="Entity"></param>
        /// <param name="Tag"></param>
        /// <returns></returns>
        public static bool EntityIs(GameObject Entity,Tag Tag)
        {
            EntityTag _Tag = Entity.GetComponent<EntityTag>();

            if (!_Tag)
            {
                Debug.Log("Game Object does not contain an EntityTag: " + Entity.ToString());
                return false;
            }
            else
            {
                return _Tag.Is(Tag);
            }
        }
Example #13
0
    Color defaultGUI = Color.white; // set to white to avoid errors (Color is non-nullable)

    #endregion Fields

    #region Methods

    // add an item to the inventory
    public void AddItem(GroundItem i)
    {
        // only add items if there's room in the inventory
        if (!IsFull())
        {
            // create a new game object and give it a held item script
            GameObject toAdd = new GameObject(i.name);
            toAdd.AddComponent<HeldItem>();
            toAdd.GetComponent<HeldItem>().Initialize(i.GetComponent<SpriteRenderer>().sprite, i.cooldown);
            toAdd.GetComponent<HeldItem>().projectile = i.projectile;

            // add the new item to the inventory
            inv[currentItems] = toAdd;
            currentItems++;
            Destroy(i.gameObject);
            Debug.Log("Item \"" + toAdd.ToString() + "\" added to inventory");
        }
    }
    //void cameraTrack_Lerp(GameObject player)
    //{
    //    //Vector3 playerPos =
    //    //mainCamera.transform.position = new Vector3(mainCamera.transform.position.x, player.transform.position.y, mainCamera.transform.position.z);
    //    Debug.Log("cameraTrack_Lerp called");
    //    Debug.Log("player available while rotation:     " + player.ToString());
    //    float wantedHeight = player.transform.position.y;
    //    Vector3 targetPos = new Vector3(mainCamera.transform.position.x, wantedHeight, mainCamera.transform.position.z);
    //    mainCamera.transform.position = Vector3.Lerp(mainCamera.transform.position, targetPos, heightDamping * Time.deltaTime);
    //}
    private void cameraMove_Lerp(GameObject player)
    {
        if(_isAdjustingCamera == true)
        {
            //_isAdjustingCamera = true;
            //mainCamera.transform.position = new Vector3(mainCamera.transform.position.x, player.transform.position.y, mainCamera.transform.position.z);
            Debug.Log("cameraMove_Lerp called");
            Debug.Log("player available while rotation:     " + player.ToString());

            float wantedHeight = player.transform.position.y;
            float currentHeight = mainCamera.transform.position.y;

            //Vector3 targetPos = new Vector3(mainCamera.transform.position.x, wantedHeight, mainCamera.transform.position.z);
            Vector3 amount = new Vector3(0, wantedHeight - currentHeight, 0);
            Debug.Log("amount" + amount);
            //mainCamera.transform.position = Vector3.MoveTowards(mainCamera.transform.position, targetPos, heightDamping * Time.deltaTime);
            //iTween.MoveAdd(mainCamera, amount, timeAdjustingCamera);
            iTween.MoveAdd(mainCamera, iTween.Hash(iT.MoveAdd.time, timeAdjustingCamera, iT.MoveAdd.amount, amount, iT.MoveAdd.oncomplete, "onAdjustCameraComplete", iT.MoveAdd.oncompletetarget, gameObject));
        }
    }
Example #15
0
    public override void Act(GameObject player, GameObject npc)
    {
        Debug.Log("FollowPath: ACT");
        Debug.Log("FollowPath: player - "+player.ToString()+". npc - "+npc.ToString());
        // Follow the path of waypoints
        // Find the direction of the current way point
        //Vector3 vel = npc.rigidbody.velocity;
        Vector3 vel = npc.GetComponent<Rigidbody>().velocity;
        Vector3 moveDir = waypoints[currentWayPoint].position - npc.transform.position;

        if (moveDir.magnitude < 1)
        {
            currentWayPoint++;
            Debug.Log("FollowPath: Incrementa WayPoint");
            if (currentWayPoint >= waypoints.Length)
            {
                currentWayPoint = 0;
            }
        }
        else
        {
            Debug.Log("FollowPath: SEGUINDO WayPoints");
            vel = moveDir.normalized * NPCControl.GetVelocityFactor();
            Debug.DrawRay(npc.transform.position,moveDir);

            // Rotate towards the waypoint
            npc.transform.rotation = Quaternion.Slerp(npc.transform.rotation,
                                                      Quaternion.LookRotation(moveDir),
                                                      2 * Time.deltaTime);

            //npc.transform.rotation.ToAngleAxis(180f,Vector3.up);
            //npc.transform.RotateAround(npc.transform.position,Vector3.up, 180.0f);
            //npc.transform.rotation = Quaternion.LookRotation(moveDir);
            npc.transform.eulerAngles = new Vector3(0, npc.transform.eulerAngles.y, 0);

        }

        // Apply the Velocity
        //npc.rigidbody.velocity = vel;
        npc.GetComponent<Rigidbody> ().velocity = vel;
    }
Example #16
0
    public override void Start()
    {

        satanicParticle = (GameObject)Resources.Load("SatanicParticle");

        Debug.Log("player found " + player);
        if (ai == aiTypes.followMop && followWho == null)
        {
            followWho = GameObject.FindGameObjectWithTag("Enemy");
            Debug.Log("following " + followWho.ToString());

        }
        player = GameObject.FindGameObjectWithTag("Player");
        base.Start();

        recipeManager = GameObject.FindGameObjectWithTag("RecipePanel").GetComponent<Recipe>();
        animator.Play("book_armature|walk");

       
        
    }
Example #17
0
	void OnFacilityCreate(GameObject _Facility)
	{
		// If trigger radius >= (Vec1 - Vec2).magnitude 
		if (m_fTriggerRadius.Get() >= ((_Facility.transform.position - transform.position).magnitude))
		{
			// If facility is NOT a member of the facility list
			if (!ListSearch(_Facility))
			{
				NearbyFacilities.Add(_Facility);
				
				//CGameShips.Ship.GetComponent<CFacilityGravity>().AddGravitySource(gameObject);
			}
			
			// Default
			else
			{
				Debug.LogError("CGravityTriggerResponse.cs attempted" +
				               "to call OnFacilityCreate(" + _Facility.ToString() + ")." +
				               "Event parameter object is already a member of the facility list.");
			}
		}
	}
	// Update is called once per frame
	void Update () {
		if (CanWin) {
			try {
				Tank = GameObject.FindGameObjectWithTag ("Tank");
				Debug.Log (Tank.ToString ());
				UpdateTxt = System.Math.Round ((Time.time), 2).ToString ();
				DoMagical.text = UpdateTxt;
			} catch {
				float WinTime = (float)System.Math.Round ((Time.time), 2);

				if (WinTime < SaveScore.GetCurrentHigh() || SaveScore.GetCurrentHigh() == 0.0f){
					string Winner = "You won in " + WinTime.ToString () + " seconds try to beat your New high score!";
					DoMagical.text = Winner;
					SaveScore.SaveScores(WinTime);
					SaveScore.LoadScores();
				} else {
					string Winner = "You won in " + WinTime.ToString () + " seconds try to beat your high score!";
					DoMagical.text = Winner;
				}
				CanWin = false;
			}
		}
	}
    public void LeftClickGrid(GameObject button)
    {
        if (!isLocalPlayer)
            return;

        if (isSelected)
        {
            if(button.name == "Grid Trash")
            {
                ThrowAwayItem(selectedName);
            }
            else if((!(items[selectedName].Equals(batSprite) || items[selectedName].Equals(pistolSprite))) && button.name == "Grid Weapon")
            {

            }
            else if(!items[selectedName].Equals(ammoSprite) && button.name == "Grid Ammo")
            {

            }
            else if(selectedName == "Grid Weapon" && !(items[button.name].Equals(pistolSprite) || items[button.name].Equals(batSprite)))
            {

            }
            else if(!items[button.name].Equals(ammoSprite) && selectedName == "Grid Ammo")
            {

            }
            else
            {
                Sprite tempImag = items[button.name];
                items[button.name] = items[selectedName];
                items[selectedName] = tempImag;
            }

            isSelected = false;
            GameObject.Find(selectedName).GetComponent<Image>().color = gridColor;
            selectedName = "";

        } else
        {
            // Cannot select trash grid
            if(button.name == "Grid Trash") return;
            // Cannot select ammo grid
            if(button.name == "Grid Ammo") return;
            // Cannot select empty grid
            if(items[button.name].Equals(gridImage)) return;

            isSelected = true;
            selectedName = button.name;
            button.GetComponent<Image>().color = selectedColor;
        }

        if (items ["Grid Weapon"].Equals (pistolSprite))
            this.GetComponent<Player_BasicAttacks>().EquipPistol();

        if(items["Grid Weapon"].Equals(batSprite))
           this.GetComponent<Player_BasicAttacks>().EquipBat();

        if(items["Grid Weapon"].Equals(gridImage))
            this.GetComponent<Player_BasicAttacks>().Unequip();

        Debug.Log (button.ToString());
    }
Example #20
0
 /// <summary>
 /// S'il existe un vertex ayant pour GameObject celui pass� en param�tre alors m_vertexSelected prend sa valeur.
 /// </summary>
 public void selectVertexFromGameObject(GameObject go)
 {
     Debug.Log("gameobject selected :" + go.ToString());
     foreach (PVertex v in m_vertices)
     {
         if (v.gameObject == go)
         {
             //on remet l'ancien vertex en bleu
             if (m_vertexSelected != null)
             {
                 m_vertexSelected.gameObject.GetComponent<Renderer>().material.SetColor("_Color",UNSELECTED_COLOR);
             }
             else if (m_vertices.Count > 0)
             {
                 PVertex selected = m_vertices.Last.Value;
                 selected.gameObject.GetComponent<Renderer>().material.SetColor("_Color",UNSELECTED_COLOR);
             }
             m_vertexSelected = v;
             //on met le nouveau en vert
             m_vertexSelected.gameObject.GetComponent<Renderer>().material.SetColor("_Color",SELECTED_COLOR);
             break;
         }
     }
 }
Example #21
0
 public void AssignCamera( GameObject target )
 {
     Debug.Log( "Targeting " + target.ToString() + " with main camera" );
     FollowCamera camera = GameObject.FindGameObjectWithTag( Tags.MainCamera ).GetComponent<FollowCamera>();
     camera.target = target;
 }
Example #22
0
	public void TouchCheck(){
		#if UNITY_IPHONE
		if( Input.touchCount > 0 ){
			Touch touch = Input.getTouch( 0 );
			if( touch.phase == TouchPhase.Began ){
				ControlPosition = touch.position;
				cameraray = Camera.main.ScreenPositionToRay( ControlPosition );
				if( Physics.Raycast( cameraray.origin, cameraray.direction, out cameraraycasthit, Mathf.Infinity, raylayermask ) ){
					TouchObject = cameraraycasthit.collider.gameObject;
					flowflg = true;
				}
			}
			else if( touch.phase == TouchPhase.Moved || touch.phase == TouchPhase.Stationary ){
				ControlPosition = touch.position;
			}
			else{
				flowflg = false;
			}
		}
		#endif

		#if UNITY_EDITOR
		/*
		//ボタンを押し続けている間
		if( Input.GetMouseButton ( 0 ) ){
			ControlPosition = Input.mousePosition;
			flowflg = true;
		}
		*/
		//ボタンを押した瞬間
		if( Input.GetMouseButtonDown( 0 ) ){
			//cameraray
			//Debug.Log ( "InputLeft" );

			ControlPosition = Input.mousePosition;
			cameraray = Camera.main.ScreenPointToRay( ControlPosition );
			//もしクリックしたときに何かオブジェクトにぶつかったとき
			if( Physics.Raycast ( cameraray.origin, cameraray.direction, out cameraraycasthit, Mathf.Infinity ) ){
				//オブジェクトの情報を返す
				RayHiter = cameraraycasthit.collider.gameObject;
				flowflg = true;
				if( RayHiter.ToString().Contains( "Button" ) ){
					RayHiter.GetComponent<Button>().OnButton( prevData, nowData );
				}
			}

			//flowflg = true;
			/*
			ControlPosition.x = ControlPosition.x;
			ControlPosition.z = ControlPosition.y;
			ControlPosition.y = -50.0f;
*/
			//ControlPosition.z = Camera.main.transform.position.y;
			//Debug.Log( ControlPosition );
			//Camera.main.ScreenToWorldPoint(clickPosition)
			//cameraray = Camera.main.ScreenPointToRay( ControlPosition );
			//cursor.z = Camera.main.transform.position.y
		}
		if( Input.GetMouseButtonUp( 0 ) ){
			ButtonUpSendflg = true;
			flowflg = false;

		}
		#endif
		/*

		cameraray = Camera.main.ScreenPointToRay( ControlPosition );
		
		if( Physics.Raycast ( cameraray.origin, cameraray.direction, out cameraraycasthit, Mathf.Infinity, raylayermask ) ){
			if( flowflg ){
				//Debug.Log( cameraraycasthit.collider.gameObject.name );
				if( cameraraycasthit.collider.gameObject.ToString().Contains( "medal" ) ){
					cameraraycasthit.collider.gameObject.GetComponent<medal>().MakeObject();
				}
				TouchObject = cameraraycasthit.collider.gameObject;
				if( Physics.Raycast ( cameraray.origin, cameraray.direction, out cameraraycasthit, Mathf.Infinity, raylayermask ) ){
					if( cameraraycasthit.collider.gameObject.ToString().Contains( "BumpObject" ) ){
						Debug.Log( "test" );
						cameraraycasthit.collider.gameObject.GetComponent<BumpObject>().UpDataPosition(  );
					}
				}

			//Instantiate( testbox, ControlPosition, Quaternion.identity );
			//flowflg = true;
			}
		}
		*/
		/*
		if ( !cameraraycasthit.collider.gameObject == null ) {
			if ( cameraraycasthit.collider.ToString ().Contains ("medal") ) {
				//cameraraycasthit.collider.GetComponent<>()
				Debug.Log (cameraraycasthit.collider.ToString());
			}
		}
		*/
		/*
		if( flowflg ){
			//当たったオブジェクトのチェック
			if( RayHiter.ToString().Contains( "Button" ) ){
				//ポジション切り替え部分
				Vector3 test;
				Debug.Log("test");

				//ポジション切り替え部分
				test = Camera.main.ScreenToWorldPoint( new Vector3( ControlPosition.x, ControlPosition.y, 50.0f ) );
				//RayHiter.GetComponent<medal>().MakeObject( test );

				if( Physics.Raycast ( cameraray.origin, cameraray.direction, out cameraraycasthit, Mathf.Infinity, raylayermask ) ){
					RayHiter = cameraraycasthit.collider.gameObject;
				}

				//cameraraycasthit.collider.gameObject.GetComponent<medal>().MakeObject( test );
			}
			*/
			/*
			if( RayHiter.ToString().Contains( "BumpObject" ) ){
				Vector3 test;
				test = Camera.main.ScreenToWorldPoint( new Vector3( ControlPosition.x, ControlPosition.y, 50.0f ) );
				RayHiter.GetComponent<BumpObject>().UpDataPosition( test );

			}
			*/
		/*
	}

		if( ButtonUpSendflg ){
			//Vector3 test;
			//test = Camera.main.ScreenToWorldPoint( new Vector3( ControlPosition.x, ControlPosition.y, 50.0f ) );
			//RayHiter.GetComponent<medal>().MakeObject( test );
*/
/*
			if( Physics.Raycast ( cameraray.origin, cameraray.direction, out cameraraycasthit, Mathf.Infinity, raylayermask ) ){
				RayHiter = cameraraycasthit.collider.gameObject;
			}
*/
			//
			//RayHiter.GetComponent<medal>().MoveOrigin( test );
		/*
		ButtonUpSendflg = false;
		}
		*/
	}
Example #23
0
    private void LoadMenu(GameObject food, Button m_button, Text m_text, GameObject m_image, GameObject i1, GameObject i2, GameObject i3, GameObject i4)
    {
        m_button.onClick.RemoveAllListeners();
        m_button.onClick.AddListener(() => ShowFood(food));
        m_text.text = food.ToString().Replace(" (UnityEngine.GameObject)", "");
        if (food.GetComponent<Food>().level > 0)
            m_text.text += "\nLevel " + food.GetComponent<Food>().level;
        else
            m_text.text += "\n<Unlock>";

        if (GetComponent<FoodVariables>().GetAllSelectedRecipes().Contains(food))
            m_button.GetComponent<Image>().color = selected;
        else
            m_button.GetComponent<Image>().color = Color.white;

        //Food
        if (food.GetComponent<Food>().menuSprite != null)
            m_image.GetComponent<Image>().sprite = food.GetComponent<Food>().menuSprite;
        else
            m_image.GetComponent<Image>().sprite = defaultFoodSprite;

        //Ingredients
        try
        {
            if (food.GetComponent<Food>().recipe[0].GetComponent<Ingredient>().image != null)
                i1.GetComponent<Image>().sprite = food.GetComponent<Food>().recipe[0].GetComponent<Ingredient>().image;
            else
                i1.GetComponent<Image>().sprite = defaultIngredientSprite;
            if (food.GetComponent<Food>().recipe[0].GetComponent<Ingredient>().quatity > 0)
                i1.GetComponent<Image>().color = Color.white;
            else
                i1.GetComponent<Image>().color = faded;
            i1.SetActive(true);
        }
        catch
        {
            i1.SetActive(false);
        }

        try
        {
            if (food.GetComponent<Food>().recipe[1].GetComponent<Ingredient>().image != null)
                i2.GetComponent<Image>().sprite = food.GetComponent<Food>().recipe[1].GetComponent<Ingredient>().image;
            else
                i2.GetComponent<Image>().sprite = defaultIngredientSprite;
            if(food.GetComponent<Food>().recipe[1].GetComponent<Ingredient>().quatity > 0)
                i2.GetComponent<Image>().color = Color.white;
            else
                i2.GetComponent<Image>().color = faded;
            i2.SetActive(true);
        }
        catch
        {
            i2.SetActive(false);
        }

        try
        {
            if (food.GetComponent<Food>().recipe[2].GetComponent<Ingredient>().image != null)
                i3.GetComponent<Image>().sprite = food.GetComponent<Food>().recipe[2].GetComponent<Ingredient>().image;
            else
                i3.GetComponent<Image>().sprite = defaultIngredientSprite;
            if (food.GetComponent<Food>().recipe[2].GetComponent<Ingredient>().quatity > 0)
                i3.GetComponent<Image>().color = Color.white;
            else
                i3.GetComponent<Image>().color = faded;
            i3.SetActive(true);
        }
        catch
        {
            i3.SetActive(false);
        }

        try
        {
            if (food.GetComponent<Food>().recipe[3].GetComponent<Ingredient>().image != null)
                i4.GetComponent<Image>().sprite = food.GetComponent<Food>().recipe[3].GetComponent<Ingredient>().image;
            else
                i4.GetComponent<Image>().sprite = defaultIngredientSprite;
            if (food.GetComponent<Food>().recipe[3].GetComponent<Ingredient>().quatity > 0)
                i4.GetComponent<Image>().color = Color.white;
            else
                i4.GetComponent<Image>().color = faded;
            i4.SetActive(true);
        }
        catch
        {
            i4.SetActive(false);
        }
    }
Example #24
0
 private int getIndex(GameObject menu)
 {
     string getIndex = menu.ToString().Substring(9, 1);
     int index = int.Parse (getIndex);
     return index;
 }
Example #25
0
    public void ShowIngredient(GameObject ingredient, int flag)
    {
        marketScroll.SetActive(false);
        f_button_panel1.SetActive(false);
        f_button_panel2.SetActive(true);

        f_food_image.SetActive(false);
        f_ingredient_image.SetActive(true);

        //Back Button
        f_close.onClick.RemoveAllListeners();
        f_close.onClick.AddListener(() => LoadMarket(menuScrollIndex));
        f_close.onClick.AddListener(() => CloseFoodSelection());


        //Description
        f_desc.text = ingredient.ToString().Replace(" (UnityEngine.GameObject)", "");

        //Food Image
        if (ingredient.GetComponent<Ingredient>().image != null)
            f_ingredient_image.GetComponent<Image>().sprite = ingredient.GetComponent<Ingredient>().image;
        else
            f_ingredient_image.GetComponent<Image>().sprite = defaultFoodSprite;

        foodSelection.SetActive(true);

        //Ingredient Images
        f_ingredient1.SetActive(false);
        f_ingredient2.SetActive(false);
        f_ingredient3.SetActive(false);
        f_ingredient4.SetActive(false);

        //Yes and No Buttons
        f_yes_button.interactable = true;
        f_yes_button.onClick.RemoveAllListeners();
        f_yes_button.onClick.AddListener(() => ingredient.GetComponent<Ingredient>().quatity++);
        f_yes_button.onClick.AddListener(() => LoadMarket(menuScrollIndex));
        f_yes_button.onClick.AddListener(() => CloseFoodSelection());

        f_no_button.interactable = true;
        f_no_button.onClick.RemoveAllListeners();
        f_no_button.onClick.AddListener(() => LoadMarket(menuScrollIndex));
        f_no_button.onClick.AddListener(() => CloseFoodSelection());

        if (flag == 0)
        {
            if (GetComponent<GlobalVariables>().money >= ingredient.GetComponent<Ingredient>().GetSalePrice())
                f_yes_button.onClick.AddListener(() => GetComponent<GlobalVariables>().AddMoney(-(ingredient.GetComponent<Ingredient>().GetSalePrice())));
            else
                f_yes_button.interactable = false;
            f_desc.text += "\nSale Price : $" + ingredient.GetComponent<Ingredient>().GetSalePrice();
        }
        else if (flag == 1)
        {
            if (GetComponent<GlobalVariables>().money >= ingredient.GetComponent<Ingredient>().marketPrice)
                f_yes_button.onClick.AddListener(() => GetComponent<GlobalVariables>().AddMoney(-(ingredient.GetComponent<Ingredient>().marketPrice)));
            else
                f_yes_button.interactable = false;
            f_desc.text += "\nMarket Price : $" + ingredient.GetComponent<Ingredient>().marketPrice;
        }
        else
        {
            if (GetComponent<GlobalVariables>().money >= ingredient.GetComponent<Ingredient>().GetRarePrice())
                f_yes_button.onClick.AddListener(() => GetComponent<GlobalVariables>().AddMoney(-(ingredient.GetComponent<Ingredient>().GetRarePrice())));
            else
                f_yes_button.interactable = false;
            f_desc.text += "\nRarity Price : $" + ingredient.GetComponent<Ingredient>().GetRarePrice();
        }
    }
Example #26
0
    public void ShowFood(GameObject food)
    {
        MenuType2 = "Food";
        menuScroll.SetActive(false);
        bool canLevel = true;
        f_food_image.SetActive(true);
        f_ingredient_image.SetActive(false);
        f_button_panel1.SetActive(true);
        f_button_panel2.SetActive(false);
        f_price_info.SetActive(false);

        //Yes and No Buttons
        f_yes_button.interactable = true;
        f_yes_button.onClick.RemoveAllListeners();
        f_yes_button.onClick.AddListener(() => ConfirmLevel(food));
        f_no_button.interactable = true;
        f_no_button.onClick.RemoveAllListeners();
        f_no_button.onClick.AddListener(() => DeclineLevel());

        //Back Button
        f_close.onClick.RemoveAllListeners();
        f_close.onClick.AddListener(() => CloseFoodSelection());
        if (MenuType == "Appetizers")
            f_close.onClick.AddListener(() => LoadAppetizers(menuScrollIndex));
        else if (MenuType == "Entrees")
            f_close.onClick.AddListener(() => LoadEntrees(menuScrollIndex));
        else if (MenuType == "Desserts")
            f_close.onClick.AddListener(() => LoadDesserts(menuScrollIndex));

        //Buttons
        f_level_button.onClick.RemoveAllListeners();
        if(food.GetComponent<Food>().level > 0)
        {
            f_level_text.text = "Level Up";
            f_price_text.text = "Pricing";
            f_price_button.interactable = true;
            f_price_button.onClick.RemoveAllListeners();
            f_price_button.onClick.AddListener(() => ShowPricingOptions(food));

            //Select Button
            f_select_button.onClick.RemoveAllListeners();
            f_select_button.interactable = true;
            if(GetComponent<FoodVariables>().GetAllSelectedRecipes().Contains(food))
            {
                //Already Selected
                SelectToggle(true, food);
                if (food.GetComponent<Food>().type == "Appetizer")
                {
                    if(GetComponent<FoodVariables>().GetAppetizers().Count == 1)
                    {
                        f_select_button.interactable = false;
                    }
                    Debug.Log("Appetizers = " + GetComponent<FoodVariables>().GetAppetizers().Count);
                }
                else if (food.GetComponent<Food>().type == "Entree")
                {
                    if (GetComponent<FoodVariables>().GetEntrees().Count == 1)
                    {
                        f_select_button.interactable = false;
                    }
                    Debug.Log("Entrees = " + GetComponent<FoodVariables>().GetEntrees().Count);
                }
            }
            else
            {
                //Can Be Selected
                SelectToggle(false, food);
            }
        }
        else
        {
            f_level_text.text = "Unlock";
            f_select_button.interactable = false;
            f_price_button.interactable = false;
        }

        //Description
        f_desc.text = food.ToString().Replace(" (UnityEngine.GameObject)", "");
        if (food.GetComponent<Food>().level > 0)
            f_desc.text += "\nLevel " + food.GetComponent<Food>().level;
        else
            f_desc.text += "\n<Unlock>";

        //Food Image
        if (food.GetComponent<Food>().menuSprite != null)
            f_food_image.GetComponent<Image>().sprite = food.GetComponent<Food>().menuSprite;
        else
            f_food_image.GetComponent<Image>().sprite = defaultFoodSprite;

        //Ingredient Images
        try
        {
            if (food.GetComponent<Food>().recipe[0].GetComponent<Ingredient>().image != null)
                f_ingredient1.GetComponent<Image>().sprite = food.GetComponent<Food>().recipe[0].GetComponent<Ingredient>().image;
            else
                f_ingredient1.GetComponent<Image>().sprite = defaultIngredientSprite;
            if (food.GetComponent<Food>().recipe[0].GetComponent<Ingredient>().quatity == 0)
            {
                canLevel = false;
                f_ingredient1.GetComponent<Image>().color = faded;
            }
            else
            {
                f_ingredient1.GetComponent<Image>().color = Color.white;
            }
            f_ingredient1.SetActive(true);
        }
        catch
        {
            f_ingredient1.SetActive(false);
        }

        try
        {
            if (food.GetComponent<Food>().recipe[1].GetComponent<Ingredient>().image != null)
                f_ingredient2.GetComponent<Image>().sprite = food.GetComponent<Food>().recipe[1].GetComponent<Ingredient>().image;
            else
                f_ingredient2.GetComponent<Image>().sprite = defaultIngredientSprite;
            if (food.GetComponent<Food>().recipe[1].GetComponent<Ingredient>().quatity == 0)
            {
                canLevel = false;
                f_ingredient2.GetComponent<Image>().color = faded;
            }
            else
            {
                f_ingredient2.GetComponent<Image>().color = Color.white;
            }
            f_ingredient2.SetActive(true);
        }
        catch
        {
            f_ingredient2.SetActive(false);
        }

        try
        {
            if (food.GetComponent<Food>().recipe[2].GetComponent<Ingredient>().image != null)
                f_ingredient3.GetComponent<Image>().sprite = food.GetComponent<Food>().recipe[2].GetComponent<Ingredient>().image;
            else
                f_ingredient3.GetComponent<Image>().sprite = defaultIngredientSprite;
            if (food.GetComponent<Food>().recipe[2].GetComponent<Ingredient>().quatity == 0)
            {
                canLevel = false;
                f_ingredient3.GetComponent<Image>().color = faded;
            }
            else
            {
                f_ingredient3.GetComponent<Image>().color = Color.white;
            }
            f_ingredient3.SetActive(true);
        }
        catch
        {
            f_ingredient3.SetActive(false);
        }

        try
        {
            if (food.GetComponent<Food>().recipe[3].GetComponent<Ingredient>().image != null)
                f_ingredient4.GetComponent<Image>().sprite = food.GetComponent<Food>().recipe[3].GetComponent<Ingredient>().image;
            else
                f_ingredient4.GetComponent<Image>().sprite = defaultIngredientSprite;
            if (food.GetComponent<Food>().recipe[3].GetComponent<Ingredient>().quatity == 0)
            {
                canLevel = false;
                f_ingredient4.GetComponent<Image>().color = faded;
            }
            else
            {
                f_ingredient4.GetComponent<Image>().color = Color.white;
            }
            f_ingredient4.SetActive(true);
        }
        catch
        {
            f_ingredient4.SetActive(false);
        }

        //Level Up Button Continued...
        if(canLevel)
        {
            f_level_button.onClick.AddListener(() => ShowLevelConfirmation());
            f_level_button.interactable = true;
        }
        else
        {
            f_level_button.interactable = false;
        }
        foodSelection.SetActive(true);
    }
    void Initialize()
    {
        Debug.Log("GameController initializing");

        DynamicObstacles = new List<DynamicObstacle>();

        for (int i = 0; i < InitialAmountOfDynamicObstacles; i++) {
            Invoke("SpawnDynamicObstacle", 3f + (float)i * 0.1f);
        }

        if (SpawnPeriodically) {
            InvokeRepeating("SpawnDynamicObstacle", SpawnInterval, SpawnInterval);
        }

        if (SwapTypesPeriodically) {
            InvokeRepeating("SwapDynamicObstacleTypes", SwapTypesInterval, SwapTypesInterval);
        }

        if (AudioController == null) {
            AudioController = this.GetComponent<AudioController>();
        }

        #region Get Player Reference
        if (Player != null) {
            _player = Player.GetComponent<PlayerController>();
            if (_player == null) {
                Debug.LogError("Could not find PlayerController component on Player: " + Player.ToString());
            }
        }
        else {
            Player = GameObject.FindGameObjectWithTag("Player");
            if (Player != null) {
                _player = Player.GetComponent<PlayerController>();
                if (_player == null) {
                    Debug.LogError("Could not find PlayerController component on Player: " + Player.ToString());
                }
            }
            else {
                Debug.LogError("Player oject has not been set on GameController and could not be automatically found");
            }
        }
        #endregion
    }
Example #28
0
 public Vector3 getTargetPosition(GameObject entity)
 {
     // formations have relatively small sizes (less than 10), so a linear search should be efficient enough
     for (int i=0; i<entityMap.Length; i++) {
         if (entityMap [i] == entity)
             return getTargetPosition (i);
     }
     throw new KeyNotFoundException ("Entity " + entity.ToString () + " not found in formation " + this.ToString ());
 }
Example #29
0
    void LoadKnightPrefs()
    {
        selectedCharacter = Knight;
        Debug.Log(selectedCharacter.ToString());

        if (GameObject.Find("Picture"))
        {
            ImageOff.enabled = true;
            GameObject SelectImage = GameObject.Find("CharacterPicture");
            Image KnightPicture = SelectImage.GetComponent<Image>();
            KnightPicture.sprite = KnightPic;
        }

        if (GameObject.Find("Atributos"))
        {
            //Procura os gameobjects
            GameObject WriteHP = GameObject.Find("HPText");
            GameObject WriteMP = GameObject.Find("MPText");
            GameObject WriteSTR = GameObject.Find("STRText");
            GameObject WriteVIT = GameObject.Find("VITText");
            GameObject WriteDEX = GameObject.Find("DEXText");
            GameObject WriteINT = GameObject.Find("INTText");

            //Escreve nas labels.
            Text textHP = WriteHP.GetComponent<Text>();
            textHP.text = "200".ToString();
            Text textMP = WriteMP.GetComponent<Text>();
            textMP.text = "50".ToString();
            Text textSTR = WriteSTR.GetComponent<Text>();
            textSTR.text = "12 *1.3".ToString();
            Text textVIT = WriteVIT.GetComponent<Text>();
            textVIT.text = "8 *1.4".ToString();
            Text textDEX = WriteDEX.GetComponent<Text>();
            textDEX.text = "2 *2.2".ToString();
            Text textINT = WriteINT.GetComponent<Text>();
            textINT.text = "2 *2.2".ToString();

        }

        if (GameObject.Find("Skills"))
        {
            GameObject WriteSkill1 = GameObject.Find("Skill1Text");
            GameObject WriteSkill2 = GameObject.Find("Skill2Text");
            GameObject WriteSkill3 = GameObject.Find("Skill3Text");

            Text textSkill1 = WriteSkill1.GetComponent<Text>();
            textSkill1.text = "Firesword".ToString();
            Text textSkill2 = WriteSkill2.GetComponent<Text>();
            textSkill2.text = "Flamesword".ToString();
            Text textSkill3 = WriteSkill3.GetComponent<Text>();
            textSkill3.text = "None".ToString();
        }

    }
Example #30
0
	public void DestroyFacility(GameObject _Facility)
	{
		if (EventOnFaciltiyDestroy != null)
		{
			EventOnFaciltiyDestroy(_Facility);
		}
		
		Debug.Log("DestroyFacility(" + _Facility.ToString() + "); was called, but the function is empty so nothing happened. Durp.");
	}