//===================================================== //===================================================== #region Private Methods #region Unity Calls private void Awake() { _wayPoints = new List <PathNode>(); _currentJobs = new List <Job>(); _gems = new Queue <Transform>(); _maskPlayer = 1 << LayerMask.NameToLayer("Player") | 1 << LayerMask.NameToLayer("Collidable"); _maskShield = 1 << LayerMask.NameToLayer("Collidable"); _thisTransform = this.transform; _thisAgent = _thisTransform.GetComponent <NavMeshAgent>(); _thisRigidbody = _thisTransform.GetComponent <Rigidbody>(); _audioSource = _thisRigidbody.GetComponent <AudioSource>(); //guard_motor = GetComponent<BotFreeMovementMotor>(); _triggerFindTarget = _thisTransform.Find("TriggerFindTarget"); _triggerFindTarget.GetComponent <SphereCollider>().radius = _triggerTargetRadius; _animation = _thisTransform.GetComponentInChildren <EnemyAnimation>(); _psDeathFx = _thisTransform.FindChild("psDeathFx").gameObject; //_debugStateRenderer = _thisTransform.FindChild( "DebugState" ).GetComponent<Renderer>(); _triggerTargetInRange = _thisTransform.FindChild("TriggerFindTarget").gameObject; // Set other defaults _currentState = eEnemyState.INIT; _health = Convert.ToInt32(SettingsManager.GetSettingsItem("ENEMY_HEALTH", GameDataManager.Instance.PlayerBossLevel)); _isPaused = false; }
public void ApplyDamage(int damage) { SpawnController spawnController = GetComponent <SpawnController>(); SpriteAnimation spriteAnimation = GetComponentInChildren <SpriteAnimation>(); PlayerMovement playerMovement = GetComponent <PlayerMovement>(); EnemyAnimation enemyAnimation = GetComponentInChildren <EnemyAnimation>(); EnemyMovement enemyMovement = GetComponent <EnemyMovement>(); if (gameObject.tag == "Player") { health -= damage; if (health == 0) { spawnController.activeRespawnTimer = true; spriteAnimation.explode = true; playerMovement.speed = 0.0f; playerMovement.turnSpeed = 0.0f; } } if (gameObject.tag == "Enemy") { health -= damage; if (health == 0) { spawnController.activeRespawnTimer = true; enemyAnimation.explode = true; enemyMovement.aiSpeed = 0.0f; enemyMovement.aiTurnSpeed = 0.0f; } } }
void Start() { agent = GetComponent <NavMeshAgent>(); patrol = GetComponent <EnemyPatrol>(); enemySenses = GetComponent <EnemySenses_3>(); anim = GetComponent <EnemyAnimation>(); enemyStats = new EnemyStats(); aiActive = true; alarmActive = false; aware = false; gameOver = false; player = GameObject.FindGameObjectWithTag("Player"); manager = FindObjectOfType <Manager>(); stats = FindObjectOfType <Statistics>(); if (isReinforcment) { aiActive = false; } if (currentState != null && aiActive) { aiActive = true; TransitionToState(currentState); } //anim.AnimationWalk(); }
public PatrolState(GameObject thisObject, Transform[] wp) { waypoints = wp; currentWayPoint = 0; stateID = StateID.PatrollingID; enemyAnimation = thisObject.GetComponent <EnemyAnimation> (); }
private void Start() { player = GameObject.Find("FPSController"); anim = GetComponent <EnemyAnimation>(); info = GetComponent <EnemyStatusInfo>(); ///ai = GetComponent<EnemyAI>(); }
private void Awake() { if (coverSpot == null) { coverSpot = new Dictionary <int, Vector3>(); } coverSpot[GetHashCode()] = Vector3.positiveInfinity; nav = GetComponent <NavMeshAgent>(); aiActive = true; enemyAnimation = gameObject.AddComponent <EnemyAnimation>(); magBullets = bullets; variables.shotsInRounds = maximumBurst; nearRadius = perceptionRadius * 0.5f; GameObject gameController = GameObject.FindGameObjectWithTag("GameController"); coverLookUp = gameController.GetComponent <CoverLookUp>(); if (coverLookUp == null) { coverLookUp = gameController.AddComponent <CoverLookUp>(); coverLookUp.Setup(generalStats.coverMask); } Debug.Assert(aimTarget.root.GetComponent <HealthBase>(), "반드시 타겟에는 생명력관련 컴포넌트를 붙여주어야 합니다."); }
/* * SerializedProperty enteranceAniName; * SerializedProperty idleAniName; * SerializedProperty runAniName; * SerializedProperty runReadyAniName; * SerializedProperty runReadyAfterAniName; * SerializedProperty readyAniName; * SerializedProperty attackAniName; * SerializedProperty knockBackAniName; * SerializedProperty hitAniName; * SerializedProperty deadAniName; * SerializedProperty flyingAniName; * * * SerializedProperty readyRushAniName; * SerializedProperty startRushAniName; * SerializedProperty rushAniName; * SerializedProperty rushAttackAniName; * * SerializedProperty angryWalkAniName; */ void OnEnable() { EnemyAnimation eAni = (EnemyAnimation)target; eAni.ani = eAni.GetComponent <SkeletonAnimation>(); eAni.enemy = eAni.GetComponent <Enemy>(); #region FindProperty enemy = serializedObject.FindProperty("enemy"); ani = serializedObject.FindProperty("ani"); //enteranceAniName = serializedObject.FindProperty("enteranceAniName"); //idleAniName = serializedObject.FindProperty("idleAniName"); //runAniName = serializedObject.FindProperty("runAniName"); //runReadyAniName = serializedObject.FindProperty("runReadyAniName"); //runReadyAfterAniName = serializedObject.FindProperty("runReadyAfterAniName"); //readyAniName = serializedObject.FindProperty("readyAniName"); //attackAniName = serializedObject.FindProperty("attackAniName"); //knockBackAniName = serializedObject.FindProperty("knockBackAniName"); //hitAniName = serializedObject.FindProperty("hitAniName"); //deadAniName = serializedObject.FindProperty("deadAniName"); //flyingAniName = serializedObject.FindProperty("flyingAniName"); //readyRushAniName = serializedObject.FindProperty("readyRushAniName"); //startRushAniName = serializedObject.FindProperty("startRushAniName"); //rushAniName = serializedObject.FindProperty("rushAniName"); //rushAttackAniName = serializedObject.FindProperty("rushAttackAniName"); //angryWalkAniName = serializedObject.FindProperty("angryWalkAniName"); #endregion }
private void Start() { animAction = GetComponent <EnemyAnimation>(); motor = GetComponent <EnemyMotor>(); gun = GetComponent <Gun>(); gunAnim = GetComponent <GunAnimation>(); }
public GameViewController(MainWindow mainWindow, string selectedGame) : base(mainWindow) { _refreshTimer = new Timer { Interval = 1000 / 60 }; _pacmanAnimationTimer = new Timer { Interval = 150 }; _obstacleTimer = new Timer { Interval = 3000 }; _spawnTimer = new Timer { Interval = 2500 }; _clock = new Clock(); _score = new Score(); _gameView = new GameView(); _gameValues = new GameValues(); _playgroundFactory = new PlaygroundFactory(); _playerFactory = new PlayerFactory(); _enemyFactory = new EnemyFactory(); _pacmanAnimation = new PacmanAnimation(); _enemyAnimation = new EnemyAnimation(); _obstacleAnimation = new ObstacleAnimation(); _step = new Step(); _position = new Position(_gameValues); _random = new Random(); _sound = new Sound(); SetContentOfMain(mainWindow, _gameView); _selectedGame = selectedGame; _gameState = GameState.Playing; SetKeyDownEvents(_gameView.GameCanvas, OnButtonKeyDown); SetKeyUpEvents(_gameView.GameCanvas, OnButtonKeyUp); _gameView.GameCanvas.Loaded += OnGameCanvasLoaded; MainWindow.Closing += OnMainWindowClosing; _refreshTimer.Elapsed += RefreshGameCanvas; _pacmanAnimationTimer.Elapsed += OnPacmanAnimationTimerElapsed; _obstacleTimer.Elapsed += OnObstacleTimerElapsed; _spawnTimer.Elapsed += OnspawnTimerElapsed; _clock.PlaytimeIsOver += OnPlaytimeIsOver; _clock.PlaytimeIsOver += _sound.OnPlaytimeIsOver; _position.CollisionDetecter.CoinCollision += OnCoinCollision; _position.CollisionDetecter.CoinCollision += _sound.OnCoinCollision; _position.CollisionDetecter.EndpointCollision += OnEndpointCollision; _position.CollisionDetecter.EndpointCollision += _sound.OnEndpointCollision; _position.CollisionDetecter.EnemyCollision += OnOnEnemyCollision; _position.CollisionDetecter.EnemyCollision += _sound.OnOnEnemyCollision; _position.CollisionDetecter.ObstacleCollision += OnObstacleCollision; _position.CollisionDetecter.ObstacleCollision += _sound.OnObstacleCollision; _pacmanAnimation.LoadPacmanImages(); _enemyAnimation.LoadPacmanImages(); _obstacleAnimation.LoadObstacleImages(); }
private void Update() { //if (Input.GetKeyDown(KeyCode.Alpha0)) Attack(); //if (_playerTransform == null) //{ // _enemyAnimator.SetTrigger(EnemyAnimation.Idle.ToString()); // return; //} timeElapsed += Time.deltaTime; wanderTimer += Time.deltaTime; attackCoolDownTimer += Time.deltaTime; if (isDead) { destroyTimer += Time.deltaTime; } if (PhotonNetwork.IsMasterClient && destroyTimer > 5) { PhotonNetwork.Destroy(gameObject); } if (agent.velocity.magnitude > 0.1f) //&& !MonsterState.Attack) { _enemyAnimator.SetTrigger(EnemyAnimation.Run.ToString()); animationState = EnemyAnimation.Run; } else { _enemyAnimator.SetTrigger(EnemyAnimation.Idle.ToString()); animationState = EnemyAnimation.Idle; } if (timeElapsed > 1) { if (!isDead) { DoThink(); DoState(); } timeElapsed = 0; } if (attackCoolDownTimer > attackCoolDown) { canAttack = true; } if (CurrentHealth <= 0 && !isDead) { _enemyAnimator.SetTrigger(EnemyAnimation.Dead.ToString()); isDead = true; GetComponent <NavMeshAgent>().enabled = false; canAttack = false; gameObject.GetComponent <NavMeshAgent>().enabled = false; } }
private void Awake() { em = GetComponent <EnemyMovement>(); sr = GetComponent <SpriteRenderer>(); eAnim = GetComponent <EnemyAnimation>(); mm = GameObject.FindGameObjectWithTag("gameManager").GetComponent <MapManager>(); eAud = GameObject.FindGameObjectWithTag("EnemyAudio").GetComponent <EnemyAudio>(); }
void Awake() { seeker = GetComponent <Seeker>(); rb = GetComponent <Rigidbody2D>(); player = GameObject.FindGameObjectWithTag("Player"); target = player.GetComponent <Transform>(); enemyAnimation = GetComponent <EnemyAnimation>(); }
private void Start() { player = GameObject.Find("FPSController"); info = GetComponent <EnemyStatusInfo>(); anim = GetComponent <EnemyAnimation>(); motor = GetComponent <EnemyMotor>(); gun = GetComponentInChildren <Gun>(); }
private void Awake() { enemyAnim = GetComponent <EnemyAnimation>(); navAgent = GetComponent <NavMeshAgent>(); target = GameObject.FindWithTag("Player").transform; }
private void Start() { target = PlayerManager.instance.Player.transform; agent = enemyRef.GetComponent <NavMeshAgent>(); EnemyManager.instance.listEnemyCombat.Add(this); enemyAnimation = new EnemyAnimation(enemyRef.GetComponent <Animator>()); rb = GetComponent <Rigidbody>(); }
void Start() { _nextTimeToMove = 0f; _isMoving = true; _enemyAnimation = GetComponent <EnemyAnimation>(); _enemyHealth = GetComponent <EnemyHealth>(); _enemyAttack = GetComponent <EnemyAttack>(); Vector2 enemyScale = transform.localScale; }
public virtual void Init() //initialise enemy subclass { Alive = true; _enemyAnim = GetComponentInChildren <EnemyAnimation>(); _enemySprite = GetComponentInChildren <SpriteRenderer>(); _rigid = GetComponent <Rigidbody2D>(); _collider = GetComponent <BoxCollider2D>(); lvlMnger = FindObjectOfType <LevelManager>(); }
public void Start() { _enemy = transform.GetChild(1).GetComponent <Transform>(); _rb = GetComponent <Rigidbody2D>(); _seeker = GetComponent <Seeker>(); _animationScript = GetComponent <EnemyAnimation>(); _enemyAnimator = _animationScript._anim; InvokeRepeating("UpdatePath", 0f, .3f); }
// Use this for initialization void Start() { player = GameObject.Find("A-IlionManager"); tPlayer = player.transform; nav = GetComponent <UnityEngine.AI.NavMeshAgent>(); nav.Warp(GetComponent <Transform>().position); scriptAnim = GetComponent <EnemyAnimation>(); TimeWaitingShoot = UnityEngine.Random.Range(120, 240); }
void Start() { aniControl = GetComponentInChildren <EnemyAnimation>(); move = GetComponent <EnemyMove>(); status = GetComponent <EnemyStatus>(); lookDirection = aniControl.GetDirection(); //적끼리의 물리적 충돌 무시 (밀림현상 방지) Physics2D.IgnoreLayerCollision(LayerMask.NameToLayer("Enemy"), LayerMask.NameToLayer("Enemy"), true); }
// Use this for initialization void Start() { hp = maxhp; atime = attackTime; Player = GameObject.Find("PlayerObj"); eAnime = GetComponent <EnemyAnimation>(); eMove = GetComponent <EnemyMove>(); boxCol = GetComponent <BoxCollider>(); }
// Start is called before the first frame update protected virtual void Start() { pfScript = GetComponent <EnemyPathfinding>(); currentState = EnemyState.IDLE; attackTimer = 0.0f; anim = GetComponentInChildren <EnemyAnimation>(); }
void Awake() { // Setting up the references. player = GameObject.FindGameObjectWithTag("Player"); playerHealth = player.GetComponent <PlayerHealth>(); enemyHealth = GetComponent <EnemyHealth>(); enemyAnim = GetComponent <EnemyAnimation> (); //anim = GetComponent<Animator>();//---->> animator }
public void Idle() { _enemyAnimator.SetTrigger(EnemyAnimation.Idle.ToString()); animationState = EnemyAnimation.Idle; if (Random.Range(0, 100) > 90) { currentState = MonsterState.Wander; } }
private void Awake() { enemyAnimation = GetComponentInChildren <EnemyAnimation>(); deathEvents = GetComponentsInChildren <IDeathEvent>().ToList(); enemyGraphics = GetComponent <IEnemyGraphicUpdater>(); enemyAttack = GetComponent <IEnemyAttack>(); enemyMove = GetComponent <IEnemyMove>(); moveToTarget = GetComponent <MoveToTarget>(); StartingColumn = Mathf.RoundToInt(transform.position.x); }
protected Transform topTransform; //Enemyの一番上のTransform protected virtual void Awake() { enemyAnimation = GetComponentInParent <EnemyAnimation>(); agent = GetComponentInParent <NavMeshAgent>(); player = GameObject.FindGameObjectWithTag(TagName.Player.String()); topTransform = GetTopTransform(); Assert.IsNotNull(enemyAnimation, "EnemyAnimationが存在しません。"); Assert.IsNotNull(agent, "NavMeshAgentが存在しません。"); Assert.IsNotNull(player, "Playerが存在しません。"); }
private int wayPointIndex; // A counter for the way point array. #endregion Fields #region Methods void Awake() { // Setting up the references. enemySight = GetComponent<EnemySight>(); enemyAnimation = GetComponent<EnemyAnimation>(); nav = GetComponent<NavMeshAgent>(); player = GameObject.Find("N40").transform; playerHealth = player.GetComponent<PlayerHealth>(); lastPlayerSighting = GameObject.Find("gameController").GetComponent<LastPlayerSighting>(); }
void enemyAttackAnimation() { //Debug.Log ("attack"); for (int i = 0; i < EnemyWings.Length; i++) { WingScript[i].setStatus(3); } theAniamtionState = EnemyAnimation.idleAnimation; }
public void AnimatorActiveCheck(EnemyAnimation anim) // 애니메이터의 액티브 상태를 체크 후 true일 경우 애니메이션 변경. { if (animator.gameObject.activeSelf) { animator.SetInteger("AnimState", (int)anim); } else { return; } }
void enemyDestroyAniamtion() { for (int i = 0; i < EnemyWings.Length; i++) { WingScript[i].setStatus(4); } //Debug.Log("destory Animation"); theAniamtionState = EnemyAnimation.nullAnimation; }
public Enemy(Level pLevel) : base("assets/sprites/enemyhitbox.png") { SetOrigin(width / 2, height / 2); rotation = 180; //Note: 0.65f for scale reference. SetScaleXY(0.65f, 0.65f); _level = pLevel; _enemyAnimation = new EnemyAnimation(this); AddChild(_enemyAnimation); }
public void doDamage(int damage) { health -= damage; dead = (health <= 0); if (dead) { currentAnimation = explodeLeft; animation = EnemyAnimation.ExplodeLeft; } }
//Start Method void Start() { collidedWithEnemy = false; ControllerManager.Instance.enemiesController.registerEnemy(this.gameObject); enemyAnimation = this.GetComponent <EnemyAnimation>(); colliderSize = new Vector2(0.9f, 0.9f); listOfPossibleDirections = new List <Directions>(); direction = Vector2.down; turningInterval = 0f; alive = true; }
// Use this for initialization void Start() { aiAgent = GetComponent <NavMeshAgent> (); gameManager = FindObjectOfType <GameManager> (); enemyAnim = GetComponentInChildren <EnemyAnimation> (); player = FindObjectOfType <PlayerHealth> (); aiAgent.speed = Random.Range(speedMinMax.x, speedMinMax.y); canChase = true; }
public void doDamage(int damage) { health -= damage; dead = (health <= 0); if (dead) { currentAnimation = die; animation = EnemyAnimation.Die; } }
private Vector3 previousSighting; // Where the player was sighted last frame. #endregion Fields #region Methods void Awake() { // Setting up the references. anim = GetComponent<Animator>(); enemyAnimation = GetComponent<EnemyAnimation>(); lastPlayerSighting = GameObject.Find("gameController").GetComponent<LastPlayerSighting>(); player = GameObject.Find("N40"); playerHealth = player.GetComponent<PlayerHealth>(); // Set the personal sighting and the previous sighting to the reset position. personalLastSighting = lastPlayerSighting.resetPosition; previousSighting = lastPlayerSighting.resetPosition; }
public BloatSack(int x, int y, ContentManager content) { idle = new Animation(138, 120, content, "Sprites\\Enemies\\BloatSack\\idle", 21, true, 30); explodeLeft = new Animation(138, 120, content, "Sprites\\Enemies\\BloatSack\\explodeleft", 10, false, 30); explodeRight = new Animation(138, 120, content, "Sprites\\Enemies\\BloatSack\\exploderight", 10, false, 30); originalRect = new Rectangle(x, y, 138, 120); shiftedRect = new Rectangle (originalRect.X, originalRect.Y, originalRect.Width, originalRect.Height); currentAnimation = idle; animation = EnemyAnimation.Idle; testingTexture = content.Load<Texture2D>("Sprites\\rectangle"); health = maxHealth; }
void Start() { if (GetComponent<EnemyMovement> ()) { if (GetComponent<EnemyAnimation> () != null) { enemyAnimation = FindObjectOfType<EnemyAnimation> (); enemyDefeatedAnimDuration = enemyAnimation.enemyDefeatedAnimDuration; } else { enemyAnimation = null; } //Auto Hook if (GetComponent<EnemyHealthManager> ()) { enemyHealthManager = GetComponent<EnemyHealthManager> (); } //else { // enemyHealthManager = GetComponentInChildren<EnemyHealthManager> (); //} // Adding "In Chidren" fixes errors, but generates whorst ones. Its probably necesary though. enemyAttack = GetComponent<EnemyAttack> (); enemyMovement = GetComponent<EnemyMovement> (); enemyAnimator = GetComponent<Animator> (); //Initial Save startingPosition = gameObject.transform.position; startingHP = enemyHealthManager.enemyHP; } else { if (GetComponentInChildren<EnemyAnimation> () != null) { enemyAnimation = FindObjectOfType<EnemyAnimation> (); enemyDefeatedAnimDuration = enemyAnimation.enemyDefeatedAnimDuration; } else { enemyAnimation = null; } //Auto Hook if (GetComponentInChildren<EnemyHealthManager> ()) { enemyHealthManager = GetComponentInChildren<EnemyHealthManager> (); } //else { // enemyHealthManager = GetComponentInChildren<EnemyHealthManager> (); //} // Adding "In Chidren" fixes errors, but generates whorst ones. Its probably necesary though. enemyAttack = GetComponentInChildren<EnemyAttack> (); enemyMovement = GetComponentInChildren<EnemyMovement> (); enemyAnimator = GetComponentInChildren<Animator> (); //Initial Save startingPosition = gameObject.transform.position; startingHP = enemyHealthManager.enemyHP; } }
void Start() { deathAnimation = false; isDead = false; EnemyMaxHP = enemyHP; LM = FindObjectOfType<LevelManager>(); enemyHurtSFX = GetComponent<AudioSource>(); if (GetComponent<Animator>() != null) { enemyAnim = FindObjectOfType<EnemyAnimation>(); } else { enemyAnim = null; } }
//Texture2D testingTexture; public GroundPatroller(int x, int y, ContentManager content) { rightToLeft = new Animation(160, 105, content, "Sprites\\Enemies\\GroundPatroller\\righttoleft", 10, false, 30); leftToRight = new Animation(160, 105, content, "Sprites\\Enemies\\GroundPatroller\\lefttoright", 10, false, 30); die = new Animation(158, 105, content, "Sprites\\Enemies\\GroundPatroller\\die", 23, false, 30); explode = new Animation(158, 105, content, "Sprites\\Enemies\\GroundPatroller\\explode", 11, false, 30); walkLeft = new Animation(158, 105, content, "Sprites\\Enemies\\GroundPatroller\\walkleft", 17, true, 30); walkRight = new Animation(158, 105, content, "Sprites\\Enemies\\GroundPatroller\\walkright", 17, true, 30); originalRect = new Rectangle(x, y, 160, 105); shiftedRect = originalRect; currentAnimation = walkRight; animation = EnemyAnimation.WalkRight; health = maxHealth; //testingTexture = content.Load<Texture2D>("Sprites\\rectangle"); }
void Start() { deathAnimation = false; isDead = false; EnemyMaxHP = enemyHP; player = FindObjectOfType<MasterController>(); LM = FindObjectOfType<LevelManager>(); warpPortal = FindObjectOfType<PortalController>(); warpKey = FindObjectOfType<KeyPickup>(); enemyHurtSFX = GetComponent<AudioSource>(); if (GetComponent<EnemyAnimation>() != null) { enemyAnim = FindObjectOfType<EnemyAnimation>(); } else { enemyAnim = null; } }
public void update(double elapsedTime) { shiftedRect.X = originalRect.X + CameraManager.getXOffset(); shiftedRect.Y = originalRect.Y + CameraManager.getYOffset(); isOnScreen = CameraManager.getViewportRect().Intersects(shiftedRect) || CameraManager.getViewportRect().Contains(shiftedRect); //ADDED CODE FOR HITING PLAYER if (!dead && shiftedRect.Intersects(Hero.getHeroHitbox())) { dead = true; Hero.dealHeroDmg(1); animation = EnemyAnimation.Explode; currentAnimation = explode; } onGround = false; foreach (Rectangle rect in ObstacleManager.getColisionRectangles()) { onGround = onGround || rect.Intersects(shiftedRect) || rect.Contains(shiftedRect); //Console.Out.WriteLine(rect.Intersects(shiftedRect)); if (rect.Intersects(shiftedRect) && (shiftedRect.Bottom - rect.Top <= 40)) { originalRect.Y -= shiftedRect.Bottom - rect.Top; shiftedRect.Y = originalRect.Y + CameraManager.getYOffset(); } if (rect.Top - 5 < shiftedRect.Bottom && (rect.Intersects(shiftedRect) || rect.Contains(shiftedRect)) && (animation == EnemyAnimation.WalkLeft || animation == EnemyAnimation.WalkRight)) { switchDirections(); } } switch (animation) { case EnemyAnimation.WalkLeft: move(Movement.Left); walkLeft.update(elapsedTime); break; case EnemyAnimation.WalkRight: move(Movement.Right); walkRight.update(elapsedTime); break; case EnemyAnimation.LeftToRight: leftToRight.update(elapsedTime); if (leftToRight.finishedAnimation()) { leftToRight.reset(); currentAnimation = walkRight; animation = EnemyAnimation.WalkRight; } break; case EnemyAnimation.RightToLeft: rightToLeft.update(elapsedTime); if (rightToLeft.finishedAnimation()) { rightToLeft.reset(); currentAnimation = walkLeft; animation = EnemyAnimation.WalkLeft; } break; case EnemyAnimation.Die: die.update(elapsedTime); break; case EnemyAnimation.Explode: explode.update(elapsedTime); break; } //INSERT CODE FOR FALLING HERE if (!onGround) { originalRect.Y += (int)(0.5 * elapsedTime); } }
// Update is called once per frame void Update() { if(attackTimer > 0)attackTimer -= Time.deltaTime; switch (myBehaviour) { case AttackBehaviour.Melee: break; case AttackBehaviour.Range: isPlayerInRange = Physics2D.OverlapCircle(transform.position, aggroRange, playerLayer); if(attackTimer <= 0 && isPlayerInRange) { if (GetComponent<Animator>() != null) { enemyAnim = FindObjectOfType<EnemyAnimation>(); if(gameObject.name == "Ranged Sound Ninja" || gameObject.name == "Spawning Ranged Sound Ninja") { attackAnimation = true; return; } } else { enemyAnim = null; } //GizmoAttack.Play (); aiming = player.transform.position - transform.position; attackTimer = timeBetweenAttacks; temp = Instantiate(projectile); trf = temp.GetComponent<Transform>(); trf.position = transform.position; rb2d = temp.GetComponent<Rigidbody2D>(); rb2d.velocity = aiming.normalized*projectileSpeed; } break; case AttackBehaviour.Bomber: if(attackTimer <= 0){ attackTimer = timeBetweenAttacks; temp = Instantiate(projectile); trf = temp.GetComponent<Transform>(); trf.position = transform.position; rb2d = temp.GetComponent<Rigidbody2D>(); rb2d.velocity = new Vector2(0,-projectileSpeed); } break; case AttackBehaviour.SideBomber: if(attackTimer <= 0){ attackTimer = timeBetweenAttacks; temp = Instantiate(projectile); trf = temp.GetComponent<Transform>(); trf.position = transform.position; rb2d = temp.GetComponent<Rigidbody2D>(); if(shootingLeft) rb2d.velocity = new Vector2(-projectileSpeed,0); else rb2d.velocity = new Vector2(projectileSpeed,0); } break; case AttackBehaviour.Stunned: stunTimer -= Time.deltaTime; if(stunTimer <=0 ){ myBehaviour = myDefaultBehaviour; } break; } }
// Use this for initialization void Start() { if (GetComponent<EnemyAnimation>() != null) { enemyAnim = FindObjectOfType<EnemyAnimation>(); } else { enemyAnim = null; } attackAnimation = false; myBehaviour = myDefaultBehaviour; playerSound = GameObject.Find("Player").GetComponent<AudioSource>(); playerScript = GameObject.Find ("Player").GetComponent<MasterController> (); player = GameObject.Find ("Player"); //GizmoAttack = GetComponent<AudioSource> (); if(Application.loadedLevel == 9) { sasuke = FindObjectOfType<SasukeController>(); } }
void Start() { //base.Start(); // get component anim = GetComponent<EnemyAnimation>(); if (anim == null) { Debug.LogError("Error On Finding Internal EnemyAnimation Script"); Application.Quit(); } // add aura GameObject aura_object = (GameObject)Instantiate(Resources.Load("Prefabs/EnemyAura"), transform.position, new Quaternion()); aura = aura_object.GetComponent<EnemyAttackAura>(); aura.SetOwner(this); }
// Use this for initialization void Start() { anim = GetComponent<EnemyAnimation>(); status = GetComponent<EnemyUnit>(); if (status == null) { Debug.LogError(gameObject.name + ".MeleeAI : No EnemyUnit script found"); Application.Quit(); } target = GameObject.Find ("Player"); if (target == null) { Debug.LogError(gameObject.name + ".MeleeAI : No Player object found"); Application.Quit(); } pathfinder = GetComponent<NavMeshAgent> (); if (pathfinder == null) { Debug.LogError(gameObject.name + ".MeleeAI : No NavMeshAgent script found"); Application.Quit(); } pathfinder.enabled = true; // create aura aura = (GameObject)Instantiate(Resources.Load("Prefabs/EnemyAura"), transform.position, new Quaternion()); aura.transform.parent = transform; var aura_script = aura.GetComponent<EnemyAttackAura>(); aura_script.damage = GetComponent<Character>().damage; aura_script.SetAuraSize(aura_size); pathfinder.updateRotation = false; }
void enemyResetAnimation() { //for tranparent //Invoke ("wingReset", sleepTime + enemyScript.wakingUpTime - 2.0f); Invoke ("wingReset", sleepTime); theAniamtionState = EnemyAnimation.idleAnimation; }
private void switchDirections() { //Console.Out.WriteLine("Swtiching Direction"); if (animation == EnemyAnimation.WalkLeft) { walkLeft.reset(); currentAnimation = leftToRight; animation = EnemyAnimation.LeftToRight; originalRect.X += 5; } else if (animation == EnemyAnimation.WalkRight) { walkRight.reset(); currentAnimation = rightToLeft; animation = EnemyAnimation.RightToLeft; originalRect.X -= 5; } }
public void update(double elapsedTime) { isOnScreen = CameraManager.getViewportRect().Intersects(shiftedRect) || CameraManager.getViewportRect().Contains(shiftedRect); shiftedRect.X = originalRect.X + CameraManager.getXOffset(); shiftedRect.Y = originalRect.Y + CameraManager.getYOffset(); heroLocation = new Vector2(CameraManager.getXOffset(), ((-1) * CameraManager.getYOffset()) - 500); if (isOnScreen) { move(elapsedTime); } //ADDED CODE FOR HITING PLAYER if (!dead && shiftedRect.Intersects(Hero.getHeroHitbox())) { dead = true; Hero.dealHeroDmg(1); animation = EnemyAnimation.ExplodeRight; currentAnimation = explodeRight; } switch (animation) { case EnemyAnimation.Idle: idle.update(elapsedTime); break; case EnemyAnimation.ExplodeLeft: explodeLeft.update(elapsedTime); break; case EnemyAnimation.ExplodeRight: explodeRight.update(elapsedTime); break; } }
void Awake() { _transform = this.transform; _mover = GetComponent<Mover>(); _animation = new EnemyAnimation(GetComponentInChildren<Animator>()); _myRenderer = GetComponentInChildren<SpriteRenderer>(); _graphicsTrans = _myRenderer.transform; _weaponManager = GameObject.FindGameObjectWithTag("WeaponManager").GetComponent<WeaponManager>(); _ticketManager = GameObject.FindGameObjectWithTag("TicketManager").GetComponent<TicketManager>(); myTeam = Team.ENEMY; Initialize(); }
void enemyWakeAnimation() { //for tranparent //Invoke ("wingGeneration", sleepTime + enemyScript.wakingUpTime - 2.0f); //Invoke ("wingGeneration", sleepTime ); theAniamtionState = EnemyAnimation.idleAnimation; }
void Start() { enemyScript = GetComponent<EnemyScript>(); theAniamtionState = EnemyAnimation.nullAnimation; currentAngle = gameObject.transform.eulerAngles.z; wingGeneration(); }
public void setEnemyAnimation(EnemyAnimation _state) { theAniamtionState = _state; }