//check and create if weapon is available public void Attack(bool isEnemy) { if (CanAttack) { shootCD = shootingRate; //create shot var shotTransform = Instantiate(shotPrefab) as Transform; //positioning shotTransform.position = transform.position; //check if enemy AmmoScript shot = shotTransform.gameObject.GetComponent <AmmoScript>(); if (shot != null) { shot.isShot = isEnemy; } //shoot at enemy movementScript move = shotTransform.gameObject.GetComponent <movementScript>(); if (move != null) { move.spDirection = this.transform.right; } } }
void Start() { //hämtar komponenten movementScript och ger mScript det värdet mScript = GetComponent <movementScript>(); }
// Use this for initialization void Start() { Debug.Log(Application.persistentDataPath); textControl = GameObject.Find("GameController").GetComponent <TextControl> (); movScript = GameObject.Find("GameController").GetComponent <movementScript> (); ue = GameObject.Find("GameController").GetComponent <userEvent> (); ue.loadEvents(); timeOfDayTimer = GameObject.Instantiate(GameObject.Find("TimerObject").GetComponent <Timer>()) as Timer; //timeOfDayTimer = GameObject.Find ("TimerObject").GetComponent<Timer>(); timeOfDay = 0; timeOfDayTimer.startTimer(10f); weatherTimer = GameObject.Instantiate(GameObject.Find("TimerObject").GetComponent <Timer>()) as Timer; //weatherTimer = GameObject.Find ("TimerObject").GetComponent<Timer>(); weatherTimer.startTimer(10f); brightnessTimer = GameObject.Instantiate(GameObject.Find("TimerObject").GetComponent <Timer>()) as Timer; //brightnessTimer = GameObject.Find ("TimerObject").GetComponent<Timer>(); brightnessTimer.startTimer(1f); fireTimer = GameObject.Instantiate(GameObject.Find("TimerObject").GetComponent <Timer>()) as Timer; //fireTimer = GameObject.Find ("TimerObject").GetComponent<Timer>(); fireTimer.startTimer(1f); randomEventTimer = GameObject.Instantiate(GameObject.Find("TimerObject").GetComponent <Timer>()) as Timer; //randomEventTimer = GameObject.Find ("timerObj").GetComponent<Timer>(); randomEventTimer.startTimer(1f); //eventList = new List<Events>(); hungerTimer = GameObject.Instantiate(GameObject.Find("TimerObject").GetComponent <Timer>()) as Timer; rangeVariables = new Dictionary <string, float> (); stateVariables = new Dictionary <string, string> (); boolVariables = new Dictionary <string, bool>(); //range variables rangeVariables.Add("brightness", brightness); rangeVariables.Add("humidity", humidity); rangeVariables.Add("timeofday", timeOfDay); rangeVariables.Add("fireenergy", fireEnergy); rangeVariables.Add("hunger", hunger); rangeVariables.Add("warmth", warmth); rangeVariables.Add("logs", logs); rangeVariables.Add("food", food); rangeVariables.Add("steps", stepsTaken); rangeVariables.Add("whichLineLogs", 0f); //stateVariables stateVariables.Add("statehumidity", stateHumidity); stateVariables.Add("statefire", stateFire); stateVariables.Add("statetime", stateTime); stateVariables.Add("statelight", stateLight); stateVariables.Add("inrangefire", "true"); //bool variables boolVariables.Add("inRangeFireB", true); //are we in range for fire effects? boolVariables.Add("onceADay", true); //happens only once a day humidity boolVariables.Add("onlyOnceFire", false); boolVariables.Add("flickerOnce", false); boolVariables.Add("firstTimeLogs", false); boolVariables.Add("hasArrivedLogs", false); boolVariables.Add("shouldArrive", false); boolVariables.Add("firstTimeFood", true); SaveFile.current = new SaveFile(); savefilename = "Reset"; save(); savefilename = ""; SaveLoad.LoadAforismer(); aforismer = SaveLoad.aforismerSave; }
void Awake() { movementScript = FindObjectOfType <movementScript>(); }