/// <summary> /// Start is called before the first frame update /// Second initialization /// </summary> void Start() { m_sActiveMenu = gameObject; try { #if UNITY_WEBGL Console.WriteLine("UnityWebGL works"); #else Console.WriteLine("UnityWebGL does not works"); #endif SetUserName(NewBehaviourScript.GetUserName()); _ms = Camera.main.GetComponent <MainScript>(); Transform rsm = transform.Find("Resume"); if (rsm != null) { m_resumeGame = rsm.GetComponent <Button>(); m_resumeGame.onClick.AddListener(Resume); m_exit = transform.Find("Exit").GetComponent <Button>(); m_exit.onClick.AddListener(_ms.FinishGame); m_saveGame = transform.Find("SaveGame").GetComponent <Button>(); m_saveGame.onClick.AddListener(Save); m_loadGame = transform.Find("LoadGame").GetComponent <Button>(); m_loadGame.onClick.AddListener(Load); } Settings.SettingsLoad(gameObject); } catch (Exception ex) { Debug.LogError("MainMenu Start exception:" + ex.Message); } }
void Shoot() { Vector3 ubicacion = new Vector3(player.transform.position.x, player.transform.position.y + 1.1f, player.transform.position.z); timer = 0f; gunLine.enabled = true; gunLight.enabled = true; shootRay.origin = ubicacion; shootRay.direction = transform.forward; gunLine.SetPosition(0, ubicacion); if (Physics.Raycast(shootRay, out shootHit, rango, shootableMask)) { //Destroy (shootHit.collider.gameObject); NewBehaviourScript resistencia = shootHit.collider.gameObject.GetComponent <NewBehaviourScript> (); if (resistencia != null) { resistencia.RegistrarImpacto(shootHit.point); } gunLine.SetPosition(1, shootHit.point); } else { Debug.Log("No se impacto con ningun elemento"); gunLine.SetPosition(1, shootRay.origin + shootRay.direction * rango); } }
private void Awake() { Instance = this; btn_out.onClick.AddListener(() => { panel_classroom.gameObject.SetActive(false); panel_menu.gameObject.SetActive(true); panel_outside.gameObject.SetActive(false); }); btn_newDay.onClick.AddListener(() => { // img_mask.DOFade(0, 0); img_mask.DOFade(1, 0.5f).OnComplete(() => { img_mask.DOFade(0, 0.5f); StartNewDay(); trans_peopleGrid.gameObject.SetActive(false); }); }); btn_showAllPeople.onClick.AddListener(() => { trans_peopleGrid.gameObject.SetActive(true); }); }
// Use this for initialization public void Start() { //scoreUI = GameObject.Find("TextMeshPro Text").GetComponent<TextMeshProUGUI>(); player = GameObject.FindGameObjectWithTag("Player").GetComponent <FirstPersonController>(); NewBehaviour = GetComponent <NewBehaviourScript>(); currenthealth = health; }
public void Render(NewBehaviourScript scene, int cameraX, int cameraY) { if (this.OptimizedOut) return; if (this.Transform == null) { this.Transform = scene.AllocateTransform(); } int x = this.X * 64 - cameraX; int y = this.Y * 64 - cameraY; string imageId = "tile_wall"; if (this.IsDoor) { imageId = "door"; } else if (this.ID == 'w') { imageId = "wtile"; } if (this.Optimizations == 1) { scene.DrawImage(this.Transform, imageId, x, y, 64, 64, false); } else { scene.DrawImageTiled(this.Transform, imageId, x, y, 64, 64, this.Optimizations * 64, 64); } }
void OnTriggerStay2D(Collider2D col) { if (Input.GetKeyDown(KeyCode.F)) { if (col.tag == "character") { GetComponent <SpriteRenderer>().color = col.GetComponent <SpriteRenderer>().color; GameObject[] obj = GameObject.FindGameObjectsWithTag("character"); float xoffset = 0; foreach (GameObject k in obj) { NewBehaviourScript crt = k.GetComponent <NewBehaviourScript>(); crt.startPos = new Vector2(col.transform.position.x + xoffset, col.transform.position.y); xoffset += 0.1f; crt.startGrav = col.GetComponent <Rigidbody2D>().gravityScale; crt.startRot = col.transform.rotation; crt.startRotVel = col.GetComponent <Rigidbody2D>().angularVelocity; crt.startVel = col.GetComponent <Rigidbody2D>().velocity; crt.startAirJump = ((NewBehaviourScript)col.GetComponent <NewBehaviourScript>()).airJump; } obj = GameObject.FindGameObjectsWithTag("movablefloor"); foreach (GameObject k in obj) { MovableObject crt = k.GetComponent <MovableObject>(); crt.startPos = k.transform.position; crt.startGrav = k.GetComponent <Rigidbody2D>().gravityScale; crt.startRot = k.transform.rotation; crt.startRotVel = k.GetComponent <Rigidbody2D>().angularVelocity; crt.startVel = k.GetComponent <Rigidbody2D>().velocity; } } } }
// Use this for initialization void Start() { paradigm = (NewBehaviourScript)ScriptableObject.CreateInstance(typeof(NewBehaviourScript)); //Instatiate face graphics //GameObject go = Instatiate( humanFaceGraphics) as GameObject; //playerPos //AAfter every time we change level CurrentParadigm.Clear(); foreach (Collider c in FaceParadigm[0].GetComponentsInChildren <Collider> ()) { CurrentParadigm.Add(c.transform.localPosition); } //Set up final score Collider[] playerTransforms = playerPos.GetComponentsInChildren <Collider> (); finalScore = 0; for (int i = 0; i < CurrentParadigm.Count; i++) { finalScore += Vector3.Distance(playerTransforms[i].transform.localPosition, CurrentParadigm[i]); } testLevel = 0; currentFaceBackground = Instantiate(FaceBackground [testLevel]); currentFaceBackground.transform.parent = faceBackgroundHolder.transform; currentFaceBackground.transform.localPosition = new Vector3(0, 0, 0); currentFaceBackground.transform.localEulerAngles = new Vector3(0, 0, 0); currentFaceBackground.transform.localScale = new Vector3(1, 1, 1); }
// When the baehavior and targetting script is called, the script should be fed the desired tergetting radius and the gameobject that should be targeted within that radius void BehaviorSetup() { DesiredAction = Action; User.AddComponent <SphereCollider>(); User.GetComponent <SphereCollider>().radius = Radius; Debug.Log("Collider made"); }
// Use this for initialization void Start() { map = GameObject.Find("Sphere").GetComponent <NewBehaviourScript>(); isMoving = false; firstPop = false; neighbourArray = new Node[map.cell]; }
// Update is called once per frame void Update() { if (enemy != null) { enemyScript = enemy.GetComponent <NewBehaviourScript>(); enemyLocation = new Vector3(enemy.transform.position.x, enemy.transform.position.y, enemy.transform.position.z); if (Vector3.Distance(enemyLocation, transform.position) > 0.3f) { transform.position = Vector3.MoveTowards(transform.position, enemyLocation, move * Time.deltaTime); } if (Vector3.Distance(enemyLocation, transform.position) < 0.7f && Vector3.Distance(enemyLocation, transform.position) > -0.7f) { enemyScript.health -= 2; } } if (health < 0) { Destroy(gameObject); } if (enemy == null) { enemy = GameObject.FindGameObjectWithTag("RedUnit"); } }
void Start() { inst = this; openBay[0] = false; openBay[1] = false; openBay[2] = false; buyBay = false; }
private void Start() { //Eac(); NewBehaviourScript script = new NewBehaviourScript(); a aa = new a(); script.Eac += aa.Debugs; script.Addlisteners("666"); }
// Use this for initialization void Start() { Debug.Log(NewBehaviourScript.imStatic); // You aren't supposed to do this :)) NewBehaviourScript new_ttest = new NewBehaviourScript(); Debug.Log(new_ttest.test); }
void Start() { junakSkripta = junak.GetComponent <NewBehaviourScript> (); steviloZogic = prostorZogic.GetComponent <SteviloZogicSkripta> (); stanje = 0; akcija.SetActive(false); }
//void OnCollisionEnter(Collision hit) //{ // Debug.Log("asdasdasd"); // Destroy(gameObject); //} void OnControllerColliderHit(ControllerColliderHit hit) { if (hit.gameObject.tag == "Enemy") { NewBehaviourScript weq = hit.gameObject.GetComponent <NewBehaviourScript>(); weq.GetBullet(this); } Destroy(gameObject); }
void Start() { GameObject tempObj = GameObject.Find("Character"); scriptInstance = tempObj.GetComponent <Character>(); GameObject tempObj2 = GameObject.Find("Sphere"); scriptCantouch = tempObj2.GetComponent <NewBehaviourScript>(); }
void Update3([CanBeNull] NewBehaviourScript script) { if (!script) { return; } var foo = script.x; }
// Use this for initialization void Start() { Navigate = this.GetComponent <NavMeshController>(); User = this.gameObject; DesiredAction = Action; User.AddComponent <SphereCollider>(); User.GetComponent <SphereCollider>().isTrigger = true; User.GetComponent <SphereCollider>().radius = Radius; Debug.Log("Collider made"); }
// Use this for initialization void Start() { map = GameObject.Find("Sphere").GetComponent <NewBehaviourScript>(); isTree = false; isRock = false; isWater = false; isWaterHorizontal = false; //cameraRotation = transform.rotation; }
private void Awake() { if (_instance != null && _instance != this) { Destroy(this.gameObject); return; } _instance = this; DontDestroyOnLoad(this.gameObject); }
private void OnCollisionEnter2D(Collision2D other) { NewBehaviourScript player = other.gameObject.GetComponent <NewBehaviourScript>(); if (player != null) { player.Takedamage(damage); player.GetComponent <Rigidbody2D>().AddForce(Vector2.right * 10 * (playerDistance.x / Mathf.Abs(playerDistance.x)), ForceMode2D.Impulse); } }
/*void OnCollisionEnter2D (Collision2D col) * { * if (col.gameObject.name.Equals ("Cube 2")) { * Debug.Log("cube 2"); * //DestroyObject(gameObject); * DestroyImmediate(gameObject); * } * }*/ void OnTriggerEnter2D(Collider2D other) { Debug.Log("noter sem spirala"); if (other.gameObject.tag.Equals("strop") || other.gameObject.tag.Equals("ovira") || other.gameObject.tag.Equals("stropN")) { skripta = junak.GetComponent <NewBehaviourScript>(); skripta.steviloSpiral--; Destroy(gameObject); Debug.Log("noter sem"); } }
// Update is called once per frame void Update() { if (Input.GetKeyUp(KeyCode.Q)) { Debug.Log(NewBehaviourScript.GetInstance()); } if (Input.GetKeyUp(KeyCode.Space)) { SceneManager.LoadScene("test2"); } }
private void OnTriggerEnter2D(Collider2D other) { NewBehaviourScript player = other.GetComponent <NewBehaviourScript>(); if (player != null) { player.SetPlayerSkill(skill); FindObjectOfType <UIManager>().SetMessage(message); Destroy(gameObject); } }
private void OnTriggerEnter2D(Collider2D other) { NewBehaviourScript playable = other.GetComponent <NewBehaviourScript>(); if (playable != null) { Inventory.inventory.AddKey(key); FindObjectOfType <UIManager>().SetMessage(key.message); Destroy(gameObject); } }
public void EnterState(FSMStateType stateType) { if (_fsmStates.ContainsKey(stateType)) { NewBehaviourScript nextState = _fsmStates[stateType]; _currentState.ExitState(); EnterState(nextState); } }
private void OnTriggerEnter2D(Collider2D other) { NewBehaviourScript player = other.GetComponent <NewBehaviourScript>(); if (player != null) { player.souls += souls; FindObjectOfType <UIManager>().UpdateUI(); gameObject.SetActive(false); } }
public bool IsWalking() { if (NewBehaviourScript.GetDirectionalInput().x != 0) { return(true); } else { return(false); } }
public void OnSubmitAccountInfo() { Dictionary <string, object> dict = new Dictionary <string, object>(); dict["BusinessType"] = 1; dict["Account"] = inputAccount.text; dict["Password"] = inputPassword.text; string json = Json.Serialize(dict); Debug.Log(json); NewBehaviourScript.sendInfo(json); }
void Start() { AudioSource = GetComponent <AudioSource>(); AudioSource.clip = ambient; AudioSource.Play(); gob = new GameObject(); Anim = GetComponent <Animator>(); behave = UiStuff.GetComponent <NewBehaviourScript>(); blackBehav = blackScreen.GetComponent <NewBehaviourScript>(); }
void OnTriggerEnter2D(Collider2D other) { Debug.Log("noter sem zoga"); if (other.gameObject.name.Equals("tla")) { rb.velocity = new Vector3(0, visina); } if (other.gameObject.name.Equals("Levo")) { smer = 1; } else if (other.gameObject.name.Equals("Desno")) { smer = -1; } else if (other.gameObject.tag.Equals("ovira")) { if (casOvire < 0) { smer *= -1; casOvire = 1; } } if (other.gameObject.tag.Equals("spirala")) { rb.velocity = new Vector3(0, silaSplita); spirala = other.gameObject.GetComponent <SpiralaScript>(); junakSkripta = junak.GetComponent <NewBehaviourScript>(); junakSkripta.steviloSpiral--; Destroy(other.gameObject); if (spirala.vrsta.Equals("jaw")) { if (InputNavigacija.zvoki) { AudioSource.PlayClipAtPoint(pok, transform.position); } Destroy(gameObject); } else { if (InputNavigacija.zvoki) { AudioSource.PlayClipAtPoint(antiPok, transform.position); } } // } }
float posy; // position d'instanciation en y #endregion Fields #region Methods // Use this for initialization void Start() { m_ListofText.Add( "Blue"); m_ListofText.Add("Green"); m_ListofText.Add("Red"); m_ListofText.Add("Yellow"); m_ListofText.Add("Orange"); m_ListofText.Add("Purple"); m_ListofText.Add("Brown"); m_Script = m_Prefab.GetComponent<NewBehaviourScript>();//récupération du script de l'objet m_Rect = m_Prefab.GetComponent<RectTransform>();//récupération de son recttransform posy = 900f;// définition de la première position en y, se souvenir que le repère va vers le haut. int i = m_ListofText.Count;// une valeur qui fait la longueur de la liste au départ, elle sera décrémentée par la suite int testvalue = m_ListofText.Count - i; // une seconde valeur qui est égale à la longueur de la liste - la valeur décrémentée, elle sert de valeur d'index pour la liste while (i>0) // tant que la valeur décrémentante est supérieur à 0, en gros tant qu'on a pas parcouru l'intégralité de la liste { for (int j =0;j<m_LineLength;j++) //une boucle qui permet de lancer plusieurs fois l'action de poser un objet et donc de construire la grille, la valeur de j doit être égale au nombre de gameobject que l'on souhaite avoir de largeur { if (i > 0)//si la valeur décrémentante est supérieure à 0, nécessaire puisque la vérification de la valeur de i ne se fait qu'en sortie de boucle et que la décrémentation de i se fait à l'intérieur de la boucle. { testvalue = m_ListofText.Count - i;//actualisation de la valeur d'index. Dans ce format-là, la liste est parcourue du [0] vers le [max] m_Script.m_ButtonName = m_ListofText[testvalue];//on change la valeur de définition du game object qui sera instancié durant cette boucle if (j == 0)// dans le cas où j est égale à 0, c'est à dire si l'objet à instancier est le premier de la ligne { posx = 100f;//définir sa position en x par rapport à son parent } else // si ce n'est pas le premier objet de la ligne { posx += (m_Rect.rect.width + 15f); // on définit sa position d'instanciation par rapport à celle de l'objet précédent et on lui accorde un léger écart } m_ButtonInstance = Instantiate(m_Prefab, new Vector3(posx, posy), transform.rotation) as GameObject;//on instancie le l'objet selon les positions précédemment définies m_ButtonInstance.transform.SetParent(this.transform);//On définie comme parent de l'objet le truc entre parenthèse (ici l'endroit où est posé le script) i--;// on décrémente la valeur décrémentante } } posy += -50f;//on définit la position d'instanciation en y de l'objet, en sortie de boucle cela permet de ne changer l'instanciation en y que l'orsque la ligne précédente est terminée. } }
public void FreeAllAssets(NewBehaviourScript scene) { Tile tile; for (int y = 0; y < this.Height; ++y) { for (int x = 0; x < this.Width; ++x) { tile = this.Tiles[x][y]; if (tile != null) { if (tile.Transform != null) { scene.RemoveTransform(tile.Transform); } } } } }
public void Render(NewBehaviourScript scene, int cameraX, int cameraY) { int width = this.Width; int height = this.Height; int x, y; Tile[][] tiles = this.Tiles; Tile tile; for (y = 0; y < height; ++y) { for (x = 0; x < width; ++x) { tile = tiles[x][y]; if (tile != null) { tile.Render(scene, cameraX, cameraY); } } } }
public void RemoveBeak(NewBehaviourScript scene) { if (this.hasBeak) { this.hasBeak = false; scene.AddSprite(new Sprite("beak", this.ModelX, this.ModelY, this)); } }
public void Render(NewBehaviourScript scene, int cameraX, int cameraY) { if (this.isDead) return; ++this.renderCounter; this.transform = this.transform ?? scene.AllocateTransform(); int x = (int)this.ModelX - 32 - cameraX; int y = (int)this.ModelY - 32 - cameraY; bool reverse = false; string imageId = null; switch (this.Type) { case "player": reverse = !this.faceRight; imageId = "player_" + (this.hasBeak ? "" : "no") + "beak_" + (this.moving ? ("walk_" + (((this.renderCounter / 8) % 2) + 1)) : "stand"); break; case "beak": imageId = "beak_" + ((this.renderCounter / 6) % 4); break; case "feather": imageId = "feather"; reverse = this.faceRight; break; case "alien": reverse = this.faceRight; string mouthSuffix = "_mouth" + (this.renderCounter % 3); if (this.moving) { imageId = "alien_walk" + ((this.renderCounter / 4) % 2 ) + mouthSuffix; } else { imageId = "alien_stand" + mouthSuffix; } break; default: throw new System.Exception("Unknown sprite ID"); } scene.DrawImage(this.transform, imageId, x, y, 64, 64, reverse); }
public void ThrowFeather(NewBehaviourScript scene) { if (featherCooldown < 0) { scene.AddSprite(new Sprite("feather", this.ModelX, this.ModelY, this)); this.featherCooldown = 30; } }
public void ApplyAutomation(NewBehaviourScript scene) { switch (this.Type) { case "beak": Level level = scene.Level; if (this.beakCounter < POINT_COUNT) { this.ModelX = xs[this.beakCounter]; this.ModelY = ys[this.beakCounter]; } else { // TODO: return to chicken double dx = this.player.ModelX - this.ModelX; double dy = this.player.ModelY - this.ModelY; double distance = System.Math.Sqrt(dx * dx + dy * dy); double v = 12; if (distance < v) { this.Kill(scene); this.player.hasBeak = true; } else { this.ModelX += v * dx / distance; this.ModelY += v * dy / distance; } } if (this.ModelX < 0) this.ModelX = 0; if (this.ModelX >= level.Width * 64) this.ModelX = level.Width * 64 - 1; if (this.ModelY < 0) this.ModelY = 0; if (this.ModelY >= level.Height * 64) this.ModelY = level.Height * 64 - 1; this.beakCounter++; break; case "feather": double fv = 9; if (this.faceRight) { this.DX = fv; } else { this.DX = -fv; } if (this.lastWasCollision) { this.Kill(scene); } break; case "alien": // if cross tile boundary check if there's ground if (this.lastWasCollision) { this.paceLeft = !this.paceLeft; this.lastWasCollision = false; } this.DX = this.paceLeft ? -1 : 1; int oldX = (int)(this.ModelX / 64); int newX = (int)((this.ModelX + this.DX) / 64); if (oldX != newX) { bool bounce = false; int groundY = (int)((this.ModelY + 33) / 64); if (groundY >= scene.Level.Height) { bounce = true; } else { if (scene.Level.Tiles[newX][groundY] == null) { bounce = true; } } if (bounce) { this.DX = 0; this.paceLeft = !this.paceLeft; } } break; default: break; } }
// Use this for initialization void Start() { pMyUnity = this.transform.GetComponent<NewBehaviourScript>(); }
public void Kill(NewBehaviourScript scene) { if (this.isDead) return; this.isDead = true; scene.RemoveTransform(this.transform); this.transform = null; }