void Spawn(AttackerScript myAttacker) { AttackerScript newAttacker = Instantiate(myAttacker, transform.position, transform.rotation); // newAttacker.transform.parent = transform; newAttacker.transform.SetParent(transform); }
public void OnEnter() { if (playerController.selectedGameObject != null) { originalCamRot = Camera.main.transform.rotation; originalCamPos = Camera.main.transform.position; attacker = playerController.selectedGameObject.GetComponent <AttackerScript>(); lookCamera = Camera.main; lookCamera.transform.position = attacker.CurrentWeapon.WeaponMount.position; lookCamera.transform.rotation = attacker.CurrentWeapon.WeaponMount.rotation; targetFoV = originalFoV = lookCamera.fieldOfView; //MouseLook.Init(transform, lookCamera.transform); CrossHairImage.gameObject.SetActive(true); CrossHairImage_Actual.gameObject.SetActive(true); Debug.Log("Locking mouse cursor"); Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; // gameEventSystem.RaiseEvent(GameEventType.AttackModeEntered, attacker.gameObject, null); } }
void OnTriggerStay2D(Collider2D otherCollider) { AttackerScript attacker = otherCollider.GetComponent <AttackerScript>(); if (attacker) { // attacker.Attack(gameObject); } }
void OnTriggerStay2D(Collider2D collider) { AttackerScript attacker = collider.gameObject.GetComponent <AttackerScript>(); if (attacker) { animate.SetTrigger("UnderAttackTrigger"); } }
private void OnTriggerEnter2D(Collider2D collider) { GameObject obj = collider.gameObject; AttackerScript attacker = obj.GetComponent <AttackerScript>(); if (attacker) { int dmg = attacker.GetDamageOnTouchdown(); playerHealth.TakeDamage(dmg); Destroy(obj); } }
private void OnTriggerEnter2D(Collider2D collider) { GameObject go = collider.gameObject; AttackerScript attacker = go.GetComponent <AttackerScript>(); Health attackerHealth = go.GetComponent <Health>(); if (attacker && attackerHealth) { attackerHealth.TakeDamage(damage); Destroy(gameObject); } }
bool IsTimeToSpawn(GameObject attacker) { // E.g. To spawn Fox every ten seconds on average, //at 10 frames per second, that means // ideally once every 100 frames, // or a probability of 1% on any frame (assuming 10FPS) // calculation: prob: 1 / (spawnPeriod * FPS) AttackerScript script = attacker.GetComponent <AttackerScript>(); float fps = 1 / Time.smoothDeltaTime; float probability = 1 / (script.seenEverySeconds * fps); return(Random.value < probability); }
void OnTriggerEnter2D(Collider2D collider) { AttackerScript attack = collider.gameObject.GetComponent <AttackerScript>(); HealthScript health = collider.gameObject.GetComponent <HealthScript>(); if (attack && health) { health.UnderAttack(damage); Destroy(gameObject); } /* bool check = collider.GetComponent<AttackerScript>(); * if(check == true) { * HealthScript health = collider.GetComponent<HealthScript>(); * health.UnderAttack(damage); * Destroy (gameObject); * }else return; */ }
bool TimeToSpawn(GameObject attackerGameObject) { AttackerScript myAttacker = attackerGameObject.GetComponent <AttackerScript>(); float secondsPerSpawn = myAttacker.spawnRate; float spawnsPerSecond = 1 / secondsPerSpawn; if (Time.deltaTime > secondsPerSpawn) { Debug.LogWarning("Spawn rate capped by frame rate"); } // Setting difficulty by progressive increase in spawn rate /* GameTimerScript gameTimer = GameObject.FindObjectOfType<GameTimerScript>(); * difficultyFactor -= (5/gameTimer.levelSeconds)* Time.deltaTime; */ float threshold = (spawnsPerSecond * Time.deltaTime) / difficultyFactor; return(Random.value < threshold); }
void Start() { animator = GetComponent <Animator>(); attackerScript = GetComponent <AttackerScript>(); }
void Start() { attacker = GetComponent <AttackerScript>(); animate = GetComponent <Animator>(); audioSource = GetComponent <AudioSource>(); }