예제 #1
0
    void OnGUI()
    {
        var  gameObj  = HelpersMethodes.GetGameObject();
        bool isWorker = false;

        if (gameObj != null)
        {
            isWorker = HelpersMethodes.GetGameObject().tag == "Worker";
        }

        if (Input.GetMouseButtonDown(0) && isWorker)
        {
            workerSelected = true;
        }
        if (workerSelected)
        {
            for (int i = 0; i < buildings.Length; i++)
            {
                if (GUI.Button(new Rect(Screen.width / 20, Screen.height / 15 + Screen.height / 12 * i, 100, 30), buildings[i].name))
                {
                    SetItem(buildings[i]);
                }
            }
        }
    }
예제 #2
0
 void Update()
 {
     buildingPlacement = HelpersMethodes.GetGameObject();
     if (currentBuilding != null && !hasPlaced)
     {
         var mousePos = HelpersMethodes.GetMousePosition();
         //currentBuilding.    Set kinetic eller noe??
         currentBuilding.transform.position = new Vector3(mousePos.x, currentBuilding.transform.position.y, mousePos.z);
         if (Input.GetMouseButtonDown(0))
         {
             hasPlaced = true;
             Worker.ListOfStaticGameObjects.Add((StaticObjects)currentBuilding);
         }
     }
 }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        //************************   Valg av arbeider   *********************************
        if (Input.GetMouseButtonDown(0) && HelpersMethodes.GetGameObject().tag == "Worker")
        {
            var clickedObject  = HelpersMethodes.GetGameObject();
            var existingObject = ListOfDynamicGameObjects.Find(x => x.gameObject.GetInstanceID() == clickedObject.GetInstanceID());
            ThisWorker = ((PlayerController)existingObject);
            Debug.Log(ThisWorker.GetInstanceID());
        }


        //************************   WoodCutter   *********************************
        if (Input.GetMouseButtonDown(1) && HelpersMethodes.GetGameObject().tag == "Tree")
        {
            Debug.Log("BamBam");
            IsWoodCutter = true;
            var clickedObject  = HelpersMethodes.GetGameObject();
            var existingObject = ListOfStaticGameObjects.Find(x => x.gameObject.GetInstanceID() == clickedObject.GetInstanceID());
            TreeImChopping = ((Tree)existingObject);
        }

        if (dist <= 2 && IsWoodCutter && WoodCollected != 1)
        {
            Debug.Log("Chopping tree");
            IsWorking = true;
            TreeImChopping.IsBeingChoppet = true;

            TimePast += Time.deltaTime;

            if (TreeImChopping != HelpersMethodes.GetGameObject() && Input.GetMouseButtonDown(1))
            {
                TimePast  = 0;
                IsWorking = false;
                TreeImChopping.IsBeingChoppet = false;
            }
            if (TimePast >= 4)
            {
                TreeImChopping.IsFalling = true;
            }
            if (TimePast >= 8)
            {
                WoodCollected = 1;
                TreeImChopping.gameObject.SetActive(false);
                IsWorking = false;
                TreeImChopping.IsBeingChoppet = false;
                Debug.Log("Tree Chopped");
                SetGoalObject <LumberCamp>();
                TimePast = 0;
            }
        }
        //************************   StonMacen   *********************************
//		if ( Input.GetMouseButtonDown (1) && HelpersMethodes.GetGameObject ().tag == "Stone" ){
//			Debug.Log ("ChoppChopp");
//			IsStoneMacen = true;
//			var clickedObject = HelpersMethodes.GetGameObject();
//			var existingObject = ListOfGameObjects.Find(x=>x.gameObject.GetInstanceID() == clickedObject.GetInstanceID());
//			StoneImCutting = ((Stone)existingObject);
//		}
//
//		if (dist <= 2 && IsStoneMacen && StoneCollected != 1){
//			Debug.Log ("Baming Stone");
//			IsWorking = true;
//
//			TimePast += Time.deltaTime;
//
//			if (StoneImCutting != HelpersMethodes.GetGameObject () && Input.GetMouseButtonDown (1)){
//				TimePast = 0;
//				IsWorking = false;
//			}
//			if (TimePast >= 1){
//				StoneCollected = 1;
//				StoneImCutting.gameObject.SetActive (false);
//				IsWorking = false;
//				Debug.Log ("Stone Smashed");
//				SetGoalObject<LumberCamp>();
//				TimePast = 0;
//			}
//		}

        //************************   Farmer   *********************************
    }
예제 #4
0
    public static List <PlayerController> ListOfDynamicGameObjects;     //Masterlisten med posisjon over alle objekter

    // Use this for initialization
    protected override void Start()
    {
        base.Start();
        ListOfStaticGameObjects  = HelpersMethodes.InitiateAllStaticGameObjects();
        ListOfDynamicGameObjects = HelpersMethodes.InitiateAllDynamicGameObjects();
    }