// Use this for initialization void Start() { animator = blaster.GetComponent<Animator> (); flag = GameObject.Find("Flag").GetComponent<FlagScript>(); isHoldingFlag = false; canAttack = true; }
public void TakeFlag(FlagScript flag) { Debug.Log($"{this.Team} ninja takes the flag!"); this.carriedFlag = flag; this.speed -= flag.playerSpeedReduceWhenGrabbed; ninjaAnimation.TakeFlagAnimation(); }
public void ConveyFlag() { this.speed += this.carriedFlag.playerSpeedReduceWhenGrabbed; this.carriedFlag.Convey(); this.carriedFlag = null; ninjaAnimation.ConveyFlagAnimation(); }
// ============================================= Methods /// <summary> /// On game start, set this object's properties. /// </summary> void Start() { // Set the game manager, if not set if (gameManager == null) { gameManager = FindObjectOfType <GameManager>(); } // Set the animator and nav mesh agent navMeshAgent = GetComponent <NavMeshAgent>(); animator = GetComponent <Animator>(); // Get the player transform //player = FindObjectOfType<PlayerController>().gameObject.transform; // Set the default state and target currentState = PlayerState.WalkingTowardsMiddle; SetTarget(); //// Add to previous call stack //previousStateStack = new Stack<KeyValuePair<Transform, PlayerState>>(); //previousStateStack.Push( // new KeyValuePair<Transform, PlayerState>(navMeshTarget, currentState)); // Update the behavior behavior = Random.Range(0, 2); // Add flags myTeamFlag = gameManager.playerFlag.GetComponent <FlagScript>(); otherTeamFlag = gameManager.enemyFlag.GetComponent <FlagScript>(); }
// Drop the carried flag at the specified position public void DropFlag(Vector3 pos) { if (flag != null) { flag.Drop(pos); flag = null; } }
public void Init() { Debug.Log($"{this.Team} ninja was created!"); isAlive = true; health = maxHealth; carriedFlag = null; powerUp = PowerUp.None; ninjaAnimation.ResurrectAnimation(); }
void RemoveObject(FlagScript visionObject) { if (objectsFlagsInRange.Contains(visionObject)) { objectsFlagsInRange.Remove(visionObject); objectsInRange.Remove(visionObject.gameObject); objectsInRangeHealthScripts.Remove(visionObject.GetComponent <HealthScript>()); unitScript.unitGroupScript.removeUnitFromRange(visionObject.gameObject); } }
void AddObject(FlagScript visionObject) { if(visionObject != null) { if(!objectsFlagsInRange.Contains(visionObject)) { objectsFlagsInRange.Add(visionObject); objectsInRange.Add(visionObject.gameObject); objectsInRangeHealthScripts.Add (visionObject.GetComponent<HealthScript>()); unitScript.unitGroupScript.addUnitToRange(visionObject.gameObject); } } }
void StartExpidition(GameObject EmptyTerrain) { GameObject flag = Instantiate(FlagPrefab, this.transform.position, Quaternion.identity) as GameObject; flag.transform.parent = this.transform; FlagScript fs = flag.GetComponent <FlagScript>(); fs.progressLevel = this.progressLevel; MapObject scr = EmptyTerrain.GetComponent <MapObject>(); scr.flag = flag; CityIsBisy = true; }
void AddObject(FlagScript visionObject) { if (visionObject != null) { if (!objectsFlagsInRange.Contains(visionObject)) { objectsFlagsInRange.Add(visionObject); objectsInRange.Add(visionObject.gameObject); objectsInRangeHealthScripts.Add(visionObject.GetComponent <HealthScript>()); unitScript.unitGroupScript.addUnitToRange(visionObject.gameObject); } } }
private void ToggleGizmos(bool refresh = false) { string currentScenePath = EditorSceneManager.GetActiveScene().path; if (string.IsNullOrEmpty(currentScenePath)) { return; } if (!refresh) { drawGizmo = !drawGizmo; } string name = "SceneNavigator"; GameObject container = GameObject.Find(name); if (drawGizmo) { if (refresh) { DestroyImmediate(container); } if (container == null) { container = new GameObject(name); container.hideFlags = HideFlags.HideAndDontSave | HideFlags.NotEditable | HideFlags.HideInInspector; } foreach (string key in flags.list.Keys) { if (customScene >= 0 && flags.list[key].scene != scenesPathArr[customScene]) { continue; } Flag flagScript = flags.list[key]; GameObject curr = new GameObject(flagScript.id); curr.transform.parent = container.transform; curr.hideFlags = HideFlags.NotEditable | HideFlags.HideInInspector | HideFlags.DontSave; FlagScript fs = curr.AddComponent <FlagScript>(); fs.flagData = flagScript; } } else { if (container != null) { DestroyImmediate(container); } } SceneView.RepaintAll(); }
public void Die() { Debug.Log($"{this.Team} ninja died!"); this.isAlive = false; if (carriedFlag != null) { this.speed += this.carriedFlag.playerSpeedReduceWhenGrabbed; carriedFlag.Drop(transform.position); carriedFlag = null; } ninjaAnimation.DieAnimation(); StartCoroutine(DieCoroutine()); }
// Use this for initialization void Start() { nbType = 0; type = Type.Wood; nbShoot = 0; holeNbr = 0; isReady = true; velLoss = 0.1f; rbBall = GetComponent <Rigidbody> (); gPlayer = GameObject.FindGameObjectWithTag("Player"); PlayerCameraS = gPlayer.GetComponent <CameraScript>(); gCurrentFlag = gFlag [holeNbr]; sFlag = gCurrentFlag.GetComponentInChildren <FlagScript> (); lastPos = myPos [0]; }
// Use this for initialization void Start() { Cursor.visible = false; carryFlag = flag.GetComponent <FlagScript>(); flagON = carryFlag.flagTaken; anim = GetComponent <Animator>(); healthManagement = gameObject.GetComponent <PlayerHealth>(); victoryManagement = victoryManagementObject.GetComponent <VictoryManagement>(); for (int i = 0; i < 2; i++) { componentsToDisable[i].enabled = false; } }
// Check for an enemy flag entering the goal void OnTriggerEnter(Collider coll) { FlagScript flag = coll.GetComponent <FlagScript>(); if (flag != null) { // Increment the team's score if (flag.team != team) { flag.Score(team); } else if (flag.par != null) { flag.par.DropFlag(transform.position); } } }
// ============================================= Methods /// <summary> /// On game start, set this object's properties. /// </summary> void Start() { // Set the game manager, if not set if (gameManager == null) { gameManager = FindObjectOfType <GameManager>(); } // Set the animator and nav mesh agent navMeshAgent = GetComponent <NavMeshAgent>(); animator = GetComponent <Animator>(); // Set the aimer and disable it aimer = GetComponentInChildren <AimIKBehaviour>(); aimer.enabled = false; // Get the player transform //player = FindObjectOfType<PlayerController>().gameObject.transform; // Set the default state and target currentState = EnemyState.WalkingTowardsMiddle; SetTarget(); // Add to previous call stack //previousStateStack = new Stack<KeyValuePair<Transform, EnemyState>>(); //previousStateStack.Push( // new KeyValuePair<Transform, EnemyState>(navMeshTarget, currentState)); // Update the behavior behavior = Random.Range(0, 2); // Add flags otherTeamFlag = gameManager.playerFlag.GetComponent <FlagScript>(); myTeamFlag = gameManager.enemyFlag.GetComponent <FlagScript>(); // Set movement speed navMeshAgent.speed = difficulty + 1.5f; // Set shooting distance playerShootDistance = 10.0f + ((difficulty - 1.0f) * 5.0f); // Set gun clip size gun.clipSize *= Mathf.CeilToInt(difficulty / 2.0f); gun.remainingBullets = gun.clipSize; gun.damage *= Mathf.Max(1.0f, difficulty / 3.0f); }
bool NearestEnemy(out GameObject nearestEnemy, out bool DestinationIsCity) { DestinationIsCity = true; float dist = 100f; GameObject newTer = null; GameObject[] allCitys = GameObject.FindGameObjectsWithTag("City"); GameObject[] allFlags = GameObject.FindGameObjectsWithTag("Flag"); foreach (GameObject g in allCitys) { CityScript scr = g.GetComponent <CityScript>(); if (dist > Vector3.Distance(g.transform.position, this.transform.position) && g != this.gameObject && g.transform.parent != this.transform.parent) { dist = Vector3.Distance(g.transform.position, this.transform.position); newTer = g; DestinationIsCity = true; } } foreach (GameObject g in allFlags) { FlagScript scr = g.GetComponent <FlagScript>(); if (dist > Vector3.Distance(g.transform.position, this.transform.position) && scr.CityCor.transform.parent != this.transform.parent) { dist = Vector3.Distance(g.transform.position, this.transform.position); newTer = g; DestinationIsCity = false; } } if (newTer == null) { nearestEnemy = null; } else { nearestEnemy = newTer; return(true); } return(false); }
void ft_loadNextFlag() { isGreen = false; gCurrentFlag = gFlag [holeNbr]; sFlag = gCurrentFlag.GetComponent <FlagScript> (); transform.position = myPos [holeNbr]; PlayerCameraS.gFlag = gHole [holeNbr]; ft_PreparForNextShoot(); isIN = false; isScoreLoaded = false; nbShoot = 0; nbType = 0; type = Type.Wood; tShoot.text = ""; tType.text = "Wood"; tHole.text = "Trou " + (holeNbr + 1).ToString(); gPanelScore.SetActive(false); transform.rotation = Quaternion.identity; lastPos = transform.position; }
// Sets all references and assigns characters #endregion void Awake() { #region Initialized Variables if (this.gameObject.name == "Urial(Clone)") { this.gameObject.name = "Urial"; } else if (this.gameObject.name == "Barachial(Clone)") { this.gameObject.name = "Barachial"; } else if (this.gameObject.name == "Lilith(Clone)") { this.gameObject.name = "Lilith"; } else if (this.gameObject.name == "Azazel(Clone)") { this.gameObject.name = "Azazel"; } // Grab the character master and sprite for assignment to the player. rb = GetComponent <Rigidbody2D>(); // Set all bools to proper state dead = false; invincible = false; FlagReference = DemonFlag.GetComponent <FlagScript>(); invincibleShield.SetActive(false); canFire = true; canShield = true; stunIconShow = true; hasFlag = false; stunned = false; stunIconToggle = true; canMelee = true; meleeing = false; shieldPowerUp = false; canThrowFlag = true; canCapture = true; invincAnim = invincibleShield.GetComponent <Animator>(); animator = GetComponent <Animator>(); #endregion }
void OnTriggerEnter(Collider col) { if (isAnFC && !hasFlag) { if (tag == "TeamBanana") { if (col.tag == "Orange") { //take the flag FlagScript flagScript = col.GetComponent <FlagScript>(); if (flagScript == null) { Debug.Log("the flag doesn't have a flag script!"); } flagScript.PickupFlag(flagPlacement); //notify the team manager. hasFlag = true; } } if (tag == "TeamOrange") { if (col.tag == "Banana") { //take the flag FlagScript flagScript = col.GetComponent <FlagScript>(); if (flagScript == null) { Debug.Log("the flag doesn't have a flag script!"); } flagScript.PickupFlag(flagPlacement); hasFlag = true; //notify the team manager } } } }
void RemoveObject(FlagScript visionObject) { if(objectsFlagsInRange.Contains(visionObject)) { objectsFlagsInRange.Remove(visionObject); objectsInRange.Remove(visionObject.gameObject); objectsInRangeHealthScripts.Remove (visionObject.GetComponent<HealthScript>()); unitScript.unitGroupScript.removeUnitFromRange(visionObject.gameObject); } }
// Update is called once per frame void Update() { if (StartEmpire != this.transform.parent.parent.gameObject) { City.war = UnityEngine.Random.Range(0, 1) == 1 ? true : false; City.CityIsBisy = false; DestroyObject(this.gameObject); } if (DestinationIsCity) { if (StartEmpire == Destination.transform.parent.gameObject) { City.war = UnityEngine.Random.Range(0, 1) == 1 ? true : false; City.CityIsBisy = false; City.army += this.UnitsCount; DestroyObject(this.gameObject); } } else if (StartEmpire == Destination.transform.parent.parent.gameObject) { City.war = UnityEngine.Random.Range(0, 1) == 1 ? true : false; City.CityIsBisy = false; City.army += this.UnitsCount; DestroyObject(this.gameObject); } if (!OnPosition) { if (Vector3.Distance(this.transform.position, Destination.transform.position) > 0.01f) { Move(); } else { OnPosition = true; if (DestinationIsCity) { CityScript cs = Destination.GetComponent <CityScript>(); float thisPower = UnitsCount * progressLevel * 0.25f + UnitsCount; float EnemyPower = (cs.army * cs.progressLevel * 0.25f + cs.army) + (cs.population * cs.progressLevel * 0.125f + cs.population * 0.5f); if (thisPower > EnemyPower) { cs.transform.parent = this.transform.parent.parent; cs.TakeColor(this.color); cs.population = 0; cs.EmpireColor = (this.color); cs.army = Convert.ToInt32((thisPower - EnemyPower) / 1.25f); City.war = UnityEngine.Random.Range(0, 1) == 1 ? true : false; City.CityIsBisy = false; DestroyObject(this.gameObject); } else { cs.population = Convert.ToInt32((EnemyPower - thisPower) / 1.625f); cs.army = 0; City.war = UnityEngine.Random.Range(0, 1) == 1 ? true : false; City.CityIsBisy = false; DestroyObject(this.gameObject); } } else { FlagScript cs = Destination.GetComponent <FlagScript>(); float thisPower = UnitsCount * progressLevel * 0.25f + UnitsCount; float EnemyPower = (cs.army * cs.progressLevel * 0.25f + cs.army) + (cs.population * cs.progressLevel * 0.125f + cs.population * 0.5f); if (thisPower > EnemyPower) { cs.transform.parent = this.transform.parent.parent; cs.CityCor = this.transform.parent.gameObject; cs.TakeColor(this.color); cs.population = 0; cs.color = this.color; cs.army = Convert.ToInt32((thisPower - EnemyPower) / 1.25f); City.war = UnityEngine.Random.Range(0, 1) == 1 ? true : false; City.CityIsBisy = false; DestroyObject(this.gameObject); } else { cs.population = Convert.ToInt32((EnemyPower - thisPower) / 1.625f); cs.army = 0; City.war = UnityEngine.Random.Range(0, 1) == 1 ? true : false; City.CityIsBisy = false; DestroyObject(this.gameObject); } } } } }
// Use this for initialization void Start() { flagscript = flag.GetComponent <FlagScript>(); teamPool = gameObject.GetComponent <TeamManager>().TeamPool; }
// Use this for initialization void Start() { cursorON = false; scoreManagerScript = scoreManagerObject.GetComponent <FlagScript>(); }