Inheritance: MonoBehaviour, IDamageable, ILiving
Exemplo n.º 1
0
    void Start()
    {
        h = GetComponent<HealthManager> ();

        h.maxHealth += health;
        h.currentHealth = h.maxHealth;
    }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        //Get PlayerController Object that already exists in the scene
        player = FindObjectOfType<PlayerController>();

        healthManager = FindObjectOfType<HealthManager>();
    }
Exemplo n.º 3
0
Arquivo: Base.cs Projeto: benrosen/RTS
 void Start()
 {
     healthManager = GetComponent<HealthManager> ();
     intervalManager = GetComponent<IntervalManager> ();
     coinManager = GetComponent<CoinManager> ();
     lastIntervalStartTime = Time.time;
 }
Exemplo n.º 4
0
 //private Thread moveThread;
 void Awake()
 {
     //print (curretTarget.position);
     healthManager = GetComponent<HealthManager> ();
     movementController = GetComponent<IMovementController> ();
     weapons = GetComponent<NPCWeaponManager> ();
 }
Exemplo n.º 5
0
 // Use this for initialization
 void Start()
 {
     player = FindObjectOfType<PlayerController> ();
     gravityStore = player.GetComponent<Rigidbody2D> ().gravityScale;
     camera = FindObjectOfType<CameraController> ();
     healthManager = FindObjectOfType<HealthManager> ();
 }
Exemplo n.º 6
0
 protected virtual void Init()
 {
     weaponManager = GetComponent<WeaponManager> ();
     movementManager = GetComponent<MovementManager> ();
     healthManager = GetComponent<HealthManager> ();
     spriteRenderer = GetComponent<SpriteRenderer> ();
     healthManager.Killed += OnKilled;
 }
Exemplo n.º 7
0
 //public GameObject gameOverScreen;
 //public PlayerController player;
 // Use this for initialization
 void Start()
 {
     countingTime = startingTime;
     theText = GetComponent<Text> ();
     thePauseMenu = FindObjectOfType<PauseMenu> ();
     theHealth = FindObjectOfType<HealthManager> ();
     //player = FindObjectOfType<PlayerController>();
 }
Exemplo n.º 8
0
	void Awake()
	{
		GM = GameMaster.GM;
		deathSequence = GetComponent<DeathSequence>();
		healthManager = GetComponent<HealthManager>();


	}
Exemplo n.º 9
0
    // Use this for initialization
    void Start()
    {
        instance = this;

        speed = minSpeed;
        rb = GetComponent<Rigidbody2D> ();
        hpManager = GetComponent<HealthManager> ();
    }
Exemplo n.º 10
0
    // Use this for initialization
    void Start()
    {
        player = FindObjectOfType<PlayerController> ();

        camera = FindObjectOfType<CameraFollow> ();

        healthManager = FindObjectOfType<HealthManager> ();
    }
Exemplo n.º 11
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player" && !drone.WhoIsOwner())
     {
         drone.ChangeActive();
         player = other.GetComponent<HealthManager>();
     }
 }
Exemplo n.º 12
0
 public CharacterBuilder CreateCharacterBuilder(GameManager gm, HealthManager hm)
 {
     if (gm == null || hm == null)
         throw new ArgumentNullException();
     _gm = gm;
     _hm = hm;
     return this;
 }
Exemplo n.º 13
0
 void Start()
 {
     if(Application.loadedLevelName == "Restore Point") tScreen = GameObject.Find ("Title Screen Canvas").GetComponent<TitleScreen> ();
     canvasObject = GameObject.Find ("Canvas");
     inventoryItem = GetComponent<InventoryItem> ();
     player = GameObject.FindWithTag ("Player");
     healthManager = GameObject.Find ("Health Manager").GetComponent<HealthManager> ();
     pauseManager = GameObject.Find ("Pause Manager").GetComponent<PauseManager> ();
 }
Exemplo n.º 14
0
 // Use this for initialization
 void Start()
 {
     //actionText = transform.Find("Text").GetComponent<Text>();
     //actionText.color = new Color (1,1,1,0);
     button = GetComponent<Button>();
     canvasTransform = GameObject.Find("Canvas").GetComponent<RectTransform>();
     playerObject = GameObject.FindGameObjectWithTag("Player");
     healthManager = GameObject.Find ("Health Manager").GetComponent<HealthManager> ();
     rTransform = GetComponent<RectTransform>();
     InvokeRepeating("ToggleText", 1, 3);
 }
Exemplo n.º 15
0
    /// <summary>
    /// HealthManagerをアタッチする。
    /// </summary>
    void AttachHealthManager()
    {
        var playerList = GameObject.FindGameObjectsWithTag("Player");
        foreach(var player in playerList)
        {
            if (player.GetComponent<NetworkView>().isMine)
            {
                healthManager = player.GetComponent<HealthManager>();
            }
        }

    }
Exemplo n.º 16
0
    void Start()
    {
        originalPosition = transform.position;

        healthManager = GetComponent<HealthManager>();

        healthBar = (GameObject)Instantiate(healthBarToClone, transform.position, Quaternion.identity);
        updateHealthBar = healthBar.GetComponent<UpdateHealthBar> ();
        updateHealthBar.targetToFollow = gameObject;
        updateHealthBar.healthBarOffset = new Vector3(0, 1f, -0.2f);

        seed = Random.value * 100;
    }
Exemplo n.º 17
0
	void Awake()
	{
		if (instance != null && instance != this)
		{
			Destroy(this.gameObject);
			return;
		}
		else
		{
			instance = this;
		}

	}
Exemplo n.º 18
0
        public Entity(int entityTypeId, Level level)
        {
            Height = 1;
            Width = 1;
            Length = 1;
            Gravity = 0.08;
            Drag = 0.02;

            EntityId = EntityManager.EntityIdUndefined;
            Level = level;
            EntityTypeId = entityTypeId;
            KnownPosition = new PlayerLocation();
            HealthManager = new HealthManager(this);
        }
Exemplo n.º 19
0
        public Physics(Game game, Player player, ContentManager Content, TanksOnAHeightmap.GameBase.Shapes.Terrain terrain, Space space)
        {
            Cannon = new Cannon(game, player.tank);
            CannonBallManager = new CannonBallManager(game);
            EnemyCannon.playerTank = player.tank;

            healthManager = new HealthManager(game, space);
            this.Content = Content;
            this.Components = game.Components;
            this.game = game;
            this.player = player;
            this.tank = player.tank;
            this.terrain = terrain;
            this.space = space;
        }
Exemplo n.º 20
0
    void Start()
    {
        sensing 		= 		GetComponent<GuardSensing> ();
        behaviour 		= 		GetComponent<GuardBehaviour> ();
        alerted 		= 		false;
        alertSystem 	= 		GameObject.Find ("Alert System").GetComponent<AlertManager>();
        pHealth 		= 		GameObject.Find ("Health Manager").GetComponent<HealthManager> ();

        // Set default state: patrol or sentry (stationary)
        if (patrolling)
        {
            behaviour.guardState = GuardBehaviour.GuardState.Patrol;
        } else {
            behaviour.guardState = GuardBehaviour.GuardState.Sentry;
        }
    }
Exemplo n.º 21
0
    /// <summary>
    /// Handle collisions between the boss and the players bullets
    /// </summary>
    public void CollideBossBullets()
    {
        HealthManager     health       = Boss.GetComponent <HealthManager> ();
        List <GameObject> bullets      = bulletManager.BulletsList;
        CollisionCircle   bossCollider = Boss.GetComponent <CollisionCircle> ();

        if (!health.Immune)
        {
            for (int i = bullets.Count - 1; i >= 0; i--)
            {
                if (bossCollider.TestCollisionCircle(bullets [i].GetComponent <CollisionCircle> ()))
                {
                    health.Hit();
                    bulletManager.DestroyBullet(i);
                }
            }
        }
    }
Exemplo n.º 22
0
    void Heal()
    {
        healthManager = GetComponent<HealthManager> ();

        if (healthManager.currentHealth < healthManager.maxHealth) {
            healthManager.currentHealth += healthPerInterval;
        }

        if (proximityManager.FriendsInRange ().Count > 0) {
            foreach (GameObject friend in proximityManager.FriendsInRange ()) {
                healthManager = friend.GetComponent<HealthManager> ();

                if (healthManager.currentHealth < healthManager.maxHealth) {
                    healthManager.currentHealth += healthPerInterval;
                }
            }
        }
    }
Exemplo n.º 23
0
        //Intercepts HealthManager's Hit method and allows me to override it with my own calculation
        public void HealthManager_Hit_Hook(On.HealthManager.orig_Hit orig, HealthManager self, HitInstance hitInstance)
        {
            //Modding.Logger.Log(self.gameObject.name + " " + hitInstance.Source.name);
            //Alternative hit damages from other sources like weaver or explosions
            Modding.Logger.Log(self.name);

            if (hitInstance.Source.name.Contains("Gas"))
            {
                //Explosion damage
                hitInstance.DamageDealt = 15 + (PlayerData.instance.nailSmithUpgrades * 5);
                orig(self, hitInstance);
                return;
            }
            else if (hitInstance.Source.name.Contains("Damager"))
            {
                //Glowing Womblings
                HeroController.instance.AddMPCharge(15);
                orig(self, hitInstance);
                return;
            }
            if (!hitInstance.Source.name.Contains("bullet"))
            {
                //Nail Damage TODO: Change this because this apparently affects environmental damage that are supposed to be OHKO
                hitInstance.DamageDealt = 3 + PlayerData.instance.nailSmithUpgrades * 3;
                orig(self, hitInstance);
                return;
            }

            HP_BulletBehaviour hpbb = hitInstance.Source.GetComponent <HP_BulletBehaviour>();
            Vector3            bulletOriginPosition = hitInstance.Source.GetComponent <HP_BulletBehaviour>().bulletOriginPosition;

            //==============Soul Gain Amount============
            int soulGainAmt = HP_Stats.CalculateSoulGain();

            //==============Damage=================
            int damage = HP_Stats.CalculateDamage(bulletOriginPosition, self.transform.position);

            DamageEnemies.HitEnemy(self, damage, HP_BulletBehaviour.bulletHitInstance, soulGainAmt);
            Modding.Logger.Log("DamageCalculator, damage dealt is " + damage + " against " + self.name);

            //==============Blood Splatter Effect=================
            //int cardinalDirection = DirectionUtils.GetCardinalDirection(hitInstance.GetActualDirection(self.transform));
            //if (!self.IsInvincible) StartCoroutine(SplatterBlood(self.gameObject, 1, cardinalDirection * 90));
        }
Exemplo n.º 24
0
    void FirePipe(int index16, bool silent)
    {
        fireDistance = meleescanDistance;
        if (DidRayHit())
        {
            anim.Play("Attack2");
            if (!silent)
            {
                SFX.clip = SFXPipeHit;
                SFX.Play();
            }
            CreateStandardImpactEffects(true);
            damageData.other = tempHit.transform.gameObject;
            if (tempHit.transform.gameObject.tag == "NPC")
            {
                damageData.isOtherNPC = true;
            }
            else
            {
                damageData.isOtherNPC = false;
            }
            damageData.hit          = tempHit;
            damageData.attacknormal = playerCamera.ScreenPointToRay(MouseCursor.drawTexture.center).direction;
            damageData.damage       = Const.a.damagePerHitForWeapon[index16];
            damageData.damage       = Const.a.GetDamageTakeAmount(damageData);
            damageData.owner        = playerCapsule;
            damageData.attackType   = Const.AttackType.Melee;
            HealthManager hm = tempHit.transform.gameObject.GetComponent <HealthManager>();
            if (hm == null)
            {
                return;
            }
            hm.TakeDamage(damageData);
            return;
        }
        fireDistance = hitscanDistance;

        if (!silent)
        {
            SFX.clip = SFXPipeMiss;
            SFX.Play();
        }
        anim.Play("Attack1");
    }
Exemplo n.º 25
0
    public EnemyBlue(string fileName, Vector2 startPos, Action <Enemy> deathEvent) : base(fileName, new Vector2(3, 3), deathEvent)
    {
        SetOrigin(width / 2, height / 2);
        SetScaleXY(10, 10);
        SetXY(startPos.x, startPos.y);

        //set health
        healthManage = new HealthManager(Setting.LIVES, CreateDeathEvent(), CreateHurtEvent(), this);

        stats.reward    = Setting.SCORE;
        stats.moveSpeed = Setting.MOVE_SPEED;
        stats.animated  = true;

        moveRect = new Rectangle(MyGame.bounds.x + width, game.height * 0.05f, MyGame.bounds.width - (width * 2), game.height * 0.3f);

        //start AI
        SetAnimation();
        StartMove();
    }
Exemplo n.º 26
0
    // Method that activates the item
    public void itemActivation(string item)
    {
        if (item.Equals("Herb") && herbs > 0)
        {
            HealthManager.healthRestore(healthToGive);
            Debug.Log("Health:" + healthToGive);
            herbs--;
        }

        if (item.Equals("Hook"))
        {
            grapple.grapple();
        }

        if (item.Equals("Boots"))
        {
            playerMove.isSpedUp(true);
        }
    }
Exemplo n.º 27
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.name == "Player")
        {
            HealthManager.HurtPlayer(damage);

            var player = other.GetComponent <PlayerController>();
            player.knockbackCount = player.knockbackTime;

            if (other.transform.position.x < transform.position.x)
            {
                player.knockRight = true;
            }
            else
            {
                player.knockRight = false;
            }
        }
    }
Exemplo n.º 28
0
    public void Attack()
    {
        Vector2      parentLocalScale = transform.parent.localScale;
        Vector2      position         = transform.position;
        Vector2      rayOrigin        = new Vector2(position.x + (transform.localScale.x / 2 * parentLocalScale.x) + 0.1f, position.y);
        RaycastHit2D hit = Physics2D.Raycast(rayOrigin, Vector2.right * parentLocalScale, range);

        Debug.DrawRay(rayOrigin, Vector2.right * parentLocalScale * range, Color.red, 1);
        Debug.Log("Weapon: Did Shot");
        if (hit.collider != null)
        {
            Debug.Log("Weapon: Did Hit");
            HealthManager victimHeathManager = hit.transform.GetComponent <HealthManager>();
            if (victimHeathManager != null)
            {
                victimHeathManager.TakeDamage(damage);
            }
        }
    }
Exemplo n.º 29
0
    public IEnumerator RespawnPlayerCo()
    {
        //generate death particle
//		Instantiate (DeathParticle, Player.transform.position, Player.transform.rotation);

        //hide player

        //Player.enabled = false;
        Player2.SetActive(false);
        Player.GetComponent <Renderer> ().enabled = false;

        //gravity reset
        GravityStore = Player.GetComponent <Rigidbody2D>().gravityScale;
        Player.GetComponent <Rigidbody2D>().gravityScale = 0f;
        Player.GetComponent <Rigidbody2D>().velocity     = Vector2.zero;

        //Point Penalty
        ScoreManager.AddPoints(-PointPenaltyOnDeath);

        //Bring Back Health
        HealthManager.ResetHealth();

        //Debug Message
        Debug.Log("Player Respawn");

        //Respawn Delay
        yield return(new WaitForSeconds(RespawnDelay));

        //Gravity Restore
        Player.GetComponent <Rigidbody2D>().gravityScale = GravityStore;

        //Match Players Transform Position
        Player.transform.position = CurrentCheckPoint.transform.position;

        //Show Player

        //Player.enabled = true;
        Player2.SetActive(true);
        Player.GetComponent <Renderer>().enabled = true;

        //Spawn Player
        //Instantiate (RespawnParticle, CurrentCheckPoint.transform.position, CurrentCheckPoint.transform.rotation);
    }
Exemplo n.º 30
0
        public Enderman(Level level) : base(EntityType.Enderman, level)
        {
            Width  = Length = 0.6;
            Height = 2.9;
            HealthManager.MaxHealth = 400;
            HealthManager.ResetHealth();
            NoAi  = true;
            Speed = 0.3f;

            AttackDamage = 7;

            TargetBehaviors.Add(new HurtByTargetBehavior(this));
            TargetBehaviors.Add(new FindAttackableTargetBehavior(this, 16));

            Behaviors.Add(new MeleeAttackBehavior(this, 1.0, 16));
            Behaviors.Add(new WanderBehavior(this, 1.0));
            Behaviors.Add(new LookAtPlayerBehavior(this, 8.0));
            Behaviors.Add(new RandomLookaroundBehavior(this));
        }
Exemplo n.º 31
0
    void Start()
    {
        // Initialize everything to default states so everything is happy
        dead           = false;
        firstSighting  = true;
        currentState   = Const.aiState.Idle;
        tickFinished   = Time.time + tickTime;
        attackFinished = Time.time;

        // Get some components that we should have
        healthManager         = GetComponent <HealthManager>();
        rbody                 = GetComponent <Rigidbody>();
        SFX                   = GetComponent <AudioSource>();
        anim                  = GetComponent <Animation>();
        lastHealth            = healthManager.health; // Initialize last health so we can check if we got hurt and go into pain state
        idealTransformForward = transform.forward;    // prefer to go forward initially, then rotate from there later towards attacker or waypoint, or node, etc.
        enemy                 = null;                 // start out with no enemy
        attacker              = null;                 // start out with no attacker
        goalPoint             = Vector3.zero;

        // If we accidentally removed an AudioSource component from the GameObject or if we never added one, let us know where this is so we can select it
        if (SFX == null)
        {
            Debug.Log("WARNING: No audio source for npc at: " + transform.position.x.ToString() + ", " + transform.position.y.ToString() + ", " + transform.position.z + ".");
        }

        if (healthManager.health > 0)
        {
            if (walkWaypoints.Length > 0 && walkWaypoints[currentWaypoint] != null)
            {
                currentState = Const.aiState.Walk;                 // If waypoints are set, start walking to them
            }
            else
            {
                currentState = Const.aiState.Idle;                 // Default to idle
            }
        }
        else
        {
            dead         = true;
            currentState = Const.aiState.Dead;
        }
    }
Exemplo n.º 32
0
 // Unity builtin
 // pos: center of sphere
 public void ExplodeInner(Vector3 pos, float oldforce, float oldradius, DamageData dd)
 {
     Collider[] colliders = Physics.OverlapSphere(pos, oldradius);
     foreach (Collider c in colliders)
     {
         if (c != null && c.GetComponent <Rigidbody>() != null)
         {
             c.GetComponent <Rigidbody>().AddExplosionForce(oldforce, pos, oldradius, 1.0f);
             if (dd != null)
             {
                 HealthManager hm = c.gameObject.GetComponent <HealthManager>();
                 if (hm != null)
                 {
                     hm.TakeDamage(dd);
                 }
             }
         }
     }
 }
Exemplo n.º 33
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.name == "Player")
     {
         HealthManager.HurtPlayer(this.damageToGive);
         var audio = other.GetComponent <AudioSource> ();
         audio.Play();
         var player = other.GetComponent <PlayerController> ();
         player.knockbackCount = player.knockbackLength;
         if (other.transform.position.x < transform.position.x)
         {
             player.knockFromRight = true;
         }
         else
         {
             player.knockFromRight = false;
         }
     }
 }
Exemplo n.º 34
0
    void RemovePotato_RPC()
    {
        isPotato = false;
        PhotonView           otherpv = GetComponent <PhotonView>();
        NetworkPlayerVehicle npv     = otherpv.GetComponentInParent <NetworkPlayerVehicle>();
        HealthManager        hm      = otherpv.gameObject.GetComponentInChildren <HealthManager>();
        TeamNameSetup        tns     = otherpv.gameObject.GetComponentInParent <TeamNameSetup>();
        HotPotatoManager     hpm     = otherpv.gameObject.GetComponentInParent <HotPotatoManager>();

        canPickupPotato = false;
        Invoke(nameof(ReactivatePickupPotato), 5f);
        myDriverId = npv.GetDriverID();
        myGunnerId = npv.GetGunnerID();


        tns.ChangeColour(false);
        potatoEffects = GetComponentInChildren <PotatoEffects>();
        potatoEffects.DeactivatePotatoEffects(myDriverId, myGunnerId);
    }
Exemplo n.º 35
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        NexusPull nexus = collision.gameObject.GetComponent <NexusPull>();

        if (nexus == null)
        {
            return;
        }

        HealthManager health = collision.gameObject.GetComponent <HealthManager>();

        if (health == null)
        {
            return;
        }

        health.TakeHit(10.0f);
        enemyHealthManager.TakeHit(float.MaxValue);
    }
Exemplo n.º 36
0
    public override void Fire()
    {
        Debug.Log(muzzleFlash);
        muzzleFlash.Play();

        RaycastHit hit;
        LayerMask  layerMask = LayerMask.GetMask("Default", isAI ? "Player" : "AI");

        if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range, layerMask: layerMask.value))
        {
            Debug.Log(hit.transform);

            HealthManager target = hit.transform.GetComponent <HealthManager>();
            if (target != null)
            {
                target.TakeDamage(damage);
            }
        }
    }
Exemplo n.º 37
0
    private void Awake()
    {
        if (!p_cController)
        {
            p_cController = GetComponent <CharacterController>();
        }
        if (!p_fpController)
        {
            p_fpController = GetComponent <FirstPersonController>();
        }
        if (!ai_navMeshAgent)
        {
            ai_navMeshAgent = GetComponent <NavMeshAgent>();
        }
        if (!ai_AIMoveController)
        {
            ai_AIMoveController = GetComponent <AIMoveController>();
        }
        if (!p_playerController)
        {
            p_playerController = GetComponent <PlayerController>();
        }
        if (!healthManager)
        {
            healthManager = GetComponent <HealthManager>();
        }

        healthManager.onDeath += () => GameOver();

        if (!p_camera)
        {
            p_camera = GetComponentInChildren <Camera>();
        }

        if (startAsPlayer)
        {
            ChangeState(ControlState.Player);
        }
        else
        {
            ChangeState(ControlState.AI);
        }
    }
Exemplo n.º 38
0
    void Awake()
    {
        hp = Player.GetComponent <HealthManager>();

        controls = Player.GetComponent <TankControl>();

        PlayerName.text = hp.Name;

        if (Player.GetComponent <PhotonView>().owner.GetTeam() == PunTeams.Team.red)
        {
            PlayerName.color = Color.red;
            PlayerHp.color   = Color.red;
        }
        else if (Player.GetComponent <PhotonView>().owner.GetTeam() == PunTeams.Team.blue)
        {
            PlayerName.color = Color.blue;
            PlayerHp.color   = Color.blue;
        }
    }
Exemplo n.º 39
0
	public float roundResetTimeCounter; // time variable between rounds

	void Start () 
	{
		//instantiate reference classes
		healthManager = FindObjectOfType<HealthManager> ();
		elderMonk = FindObjectOfType<ElderMonk> ();
		hiddenText = FindObjectOfType<HiddenText> ();
		playerController = FindObjectOfType<PlayerController> ();

		//find animators
		anim01 = Player01.GetComponent<Animator> ();
		anim02 = Player02.GetComponent<Animator> ();

		//player02 rigidbody
		body02 = Player02.GetComponent<Rigidbody2D> ();

		//set starting values
		roundEnd = false;
		roundResetTimeCounter = roundResetTime;
	}
Exemplo n.º 40
0
    // Use this for initialization
    void Start()
    {
        CameraAC.enabled    = false;
        _target             = GameObject.FindGameObjectWithTag("Player").transform;
        _lastTargetPosition = _target.position;
        _offsetZ            = (transform.position - _target.position).z;
        transform.parent    = null;
        _playerHealth       = _target.gameObject.GetComponent <HealthManager> ();
        _cameraStart        = GetComponent <CameraStart> ();
        _cameraEnd          = GetComponent <CameraEnd> ();

        Vector3 PlayerPos = GameObject.FindGameObjectWithTag("Player").transform.position;
        Vector3 Pos       = new Vector3(PlayerPos.x, PlayerPos.y, -10);

        Pos.x                 = Mathf.Clamp(Pos.x, -XBound, XBound);
        Pos.y                 = Mathf.Clamp(Pos.y, -YBound, YBound);
        _cameraTrans          = this.transform;
        _cameraTrans.position = Pos;
    }
Exemplo n.º 41
0
    void Start()
    {
        // Let cursor lock state to locked
        Cursor.lockState = CursorLockMode.Locked;

        // Get gun object and update its scale
        gun = this.transform.GetChild(1);
        Vector3 gunScale = gun.transform.localScale;

        gunScaleY = gunScale.y;

        // Get components
        rigidBody     = GetComponent <Rigidbody>();
        sprintManager = GetComponent <SprintManager>();
        healthManager = GetComponent <HealthManager>();

        // Set it outside the players control initially
        inControl = false;
    }
Exemplo n.º 42
0
    public void Spawn()
    {
        gameObject.SetActive(true);

        if (enemyHealth == null)
        {
            enemyHealth = GetComponent <HealthManager>();
        }
        if (character == null)
        {
            character = GetComponent <CharacterObject>();
        }
        character.OnSpawn();
        enemyHealth.SetMaxHealth();
        enemyHealth.IsDead = false;
        IsSpawned          = true;
        transform.SetParent(null);
        transform.position = spawnPos;
    }
Exemplo n.º 43
0
    // Update is called once per frame
    void Update()
    {
        if (thePauseMenu.isPaused)
        {
            return;
        }

        countingTime -= Time.deltaTime;

        if (countingTime <= 0)
        {
            //gameOverScreen.SetActive(true);
            //player.gameObject.SetActive(false);

            HealthManager.KillPlayer();
        }

        theText.text = "" + Mathf.Round(countingTime);
    }
Exemplo n.º 44
0
    void Awake()
    {
        // Add event subscription with callback
        GameManager.onGameStartEvent  += EnablePlayer;
        GameManager.onKnightsWinEvent += Celebrate;
        animator      = gameObject.GetComponent <Animator>();
        healthManager = GetComponent <HealthManager>();
        inputManager  = GetComponent <KnightInputManager>();
        soundManager  = GetComponent <SoundManager>();

        // Get Behaviors
        moveBehavior       = GetComponent <MoveBehavior>();
        attackBehavior     = GetComponent <AttackBehavior>();
        blockBehavior      = GetComponent <BlockBehavior>();
        jumpBehavior       = GetComponent <JumpBehavior>();
        takeDamageBehavior = GetComponent <TakeDamageBehavior>();

        //Invoke("Die", 5);
    }
Exemplo n.º 45
0
    void OnTriggerEnter2D(Collider2D other)
    {     //If anything collides this object
        if (other.name == "Player")
        { //If who collided was the player,
            HealthManager.HurtPlayer(damageToGive);

            other.GetComponent <AudioSource>().Play();

            //Knockback doesn't work

            /*var player = other.GetComponent<PlayerController>();
             * player.knockbackCount = player.knockbackLength;
             *
             * if (other.transform.position.x < transform.position.x)
             *  player.knockFromRight = true;
             * else
             *  player.knockFromRight = false;*/
        }
    }
Exemplo n.º 46
0
    private void Fire()
    {
        if (fireTimer < fireRate || isReloading || isRunning)
        {
            return;
        }
        RaycastHit hit;

        if (Physics.Raycast(shootPoint.position, shootPoint.transform.forward + Random.onUnitSphere * accuracy, out hit, range))
        {
            GameObject hitSpark = Instantiate(hitSparkPrefab, hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal));
            hitSpark.transform.SetParent(hit.transform);
            Destroy(hitSpark, 0.5f);
            GameObject hitHole = Instantiate(hitHolePrefab, hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal));
            hitHole.transform.SetParent(hit.transform);
            Destroy(hitHole, 5.0f);
            Recoil();
            BulletEffect();
            HealthManager healthManager = hit.transform.GetComponent <HealthManager>();
            if (healthManager)
            {
                healthManager.ApplyDamage(damage);
            }

            EnemyManager enemyManager = hit.transform.GetComponentInParent <EnemyManager>();
            if (enemyManager)
            {
                enemyManager.ApplyDamage(damage);
            }

            Rigidbody rigidbody = hit.transform.GetComponent <Rigidbody>();
            if (rigidbody)
            {
                rigidbody.AddForceAtPosition(transform.forward * 5.0f * damage, transform.position);
            }
        }
        currentBullets--;
        fireTimer = 0.0f;
        audioSource.PlayOneShot(shootSound);
        anim.CrossFadeInFixedTime("Fire", 0.01f);
        muzzleFlash.Play();
        bulletsText.text = currentBullets + " / " + bulletsTotal;
    }
    // Looks for Health Manager on collided object to take health then destroys this gameobject
    private void CollisionResult(GameObject other, Vector3 point, Vector3 normal)
    {
        HealthManager healthManager = other.GetComponent <HealthManager>();

        if (healthManager != null)
        {
            healthManager.TakeHealth(fDamage);
        }

        if (other.layer == LayerMask.NameToLayer("Environment") ||
            other.layer == LayerMask.NameToLayer("MovingPlatform"))
        {
            impactAudio.Play();

            Instantiate(goBulletImpact, point, Quaternion.Euler(normal));
        }

        DestroyProjectile();
    }
    void DisableScripts()
    {
        // LevelSystem levelSystem = GetComponentInChildren<LevelSystem>();
        // FundSystem fundSystem = GetComponentInChildren<FundSystem>();
        HealthManager healthManager = GetComponentInChildren <HealthManager>();
        UpdateHealth  updateHealth  = GetComponent <UpdateHealth>();

        WeaponBase[] weapons = GetComponentsInChildren <WeaponBase>();

        // levelSystem.enabled = false;
        // fundSystem.enabled = false;
        healthManager.enabled = false;
        updateHealth.enabled  = false;

        foreach (WeaponBase weapon in weapons)
        {
            weapon.enabled = false;
        }
    }
Exemplo n.º 49
0
    void Init()
    {
        pathTime       = animTime = 0;
        rotationDir    = RallyPos = PosMem = storedPos = Vector3.zero;
        nameCheckPoint = GameObject.Find("NameCheck").GetComponent <Collider>();
        rifle          = GetComponentInChildren <FindRifle>().gameObject;
        anim           = GetComponentInChildren <Animator>();
        aSource        = GetComponent <AudioSource>();
        visibleObjects = new List <GameObject>();
        nameReady      = false;
        //Get Components
        m_SkinRenderer            = GetComponentInChildren <SkinnedMeshRenderer>();
        m_HealthManager           = GetComponentInChildren <HealthManager>();
        m_NavAgent                = GetComponent <UnityEngine.AI.NavMeshAgent>();
        m_NavAgent.updateRotation = false;
        m_Camera        = GetComponentInChildren <Camera>();
        m_PaintballPool = PoolSystem.FindPool("Projectile");
        //set the health according to what enemy type it is
        if (isLeader)
        {
            m_HealthManager.SetEntityToMinionLeader();
            transform.localScale = new Vector3(0.75f, 0.75f, 0.75f);
        }
        else
        {
            m_HealthManager.SetEntityToMinion();
        }
        currentState = States.Patrol;

        //set things to false
        SwitchOff();

        //set things to zero
        gunTimer = targetLockTimer = pathTime = 0; //floats

        target = null;

        //precalculations
        m_FireRate = 60.0f / m_FireRate;
        sinTurn    = Mathf.Sin(30.0f);
        cosTurn    = Mathf.Cos(30.0f);
    }
Exemplo n.º 50
0
    // Use this for initialization
    private void Start()
    {
        m_body            = GetComponent <Rigidbody2D>();
        m_playerRenderer  = GetComponent <SpriteRenderer>();
        m_animator        = GetComponent <Animator>();
        m_collider        = GetComponent <Collider2D>();
        m_laserLine       = GetComponent <LineRenderer>();
        m_myHealthManager = GetComponent <HealthManager>();

        items = new List <Pickup>();

        if (Camera == null)
        {
            Camera = Camera.main;
        }

        m_cameraController = Camera.GetComponent <CameraController>();

        m_laserLine.material = new Material(Shader.Find("Sprites/Default"));

        // A simple 2 color gradient with a fixed alpha of 1.0f.
        float    alpha    = 1.0f;
        Gradient gradient = new Gradient();

        gradient.SetKeys(
            colorKeys: new[]
        {
            new GradientColorKey(new Color(1f, 0.58f, 0f), 0.0f),
            new GradientColorKey(new Color(1f, 0.85f, 0f), 1.0f)
        },
            alphaKeys: new[]
        {
            new GradientAlphaKey(alpha, 0.0f),
            new GradientAlphaKey(alpha, 1.0f)
        }
            );
        m_laserLine.colorGradient = gradient;

        m_shootableMask = LayerMask.GetMask("Shootable");

        HealthSlider.value = m_myHealthManager.MaxHealth;
    }
Exemplo n.º 51
0
    void Start()
    {
        //get the xyz values of this object
        playerSize = this.GetComponent <Collider>().bounds.size;

        //projectile variables
        projectileCooldownCount = PROJECTILE_COOLDOWN; //init cooldown count
        PROJECTILE_OFFSET       = playerSize.z;        //offset for the projectile position relative to player

        //keep the player on the ground
        this.gameObject.transform.position = new Vector3(this.gameObject.transform.position.x, playerSize.y / 2, this.gameObject.transform.position.z);


        //apply a colour to the material of the mesh renderer component
        //MeshRenderer renderer = this.gameObject.GetComponent<MeshRenderer>();
        //renderer.material.color = Color.white;

        //assign the main camera to this variable
        mainCamera = FindObjectOfType <Camera> ();

        //assign the players rigid body to this variable
        //playerRigidBody = GetComponent<Rigidbody>();

        // assign the character controller
        controller = GetComponent <CharacterController> ();


        //ground boundaries
        GameObject ground             = GameObject.Find("Ground");
        Renderer   groundSizeRenderer = ground.GetComponent <Renderer>();
        Vector3    groundSize         = groundSizeRenderer.bounds.size;

        //divided by 2 for maths purposes (origin of ground is at 0,0 and largeset x is groundSize.x/2)
        groundSizeX = groundSize.x / 2;
        groundSizeZ = groundSize.z / 2;

        //handle the health of the player here
        healthManager = this.gameObject.GetComponent <HealthManager>();
        //find the left and right body
        playerBodyLeft  = GameObject.Find("Player/Player Spawn Particle System/playerleft");
        playerBodyRight = GameObject.Find("Player/Player Spawn Particle System/playerright");
    }
Exemplo n.º 52
0
        private void SetDamages(On.HealthManager.orig_TakeDamage orig, HealthManager owner, HitInstance
                                hit)
        {
            Log($@"Creating HitInstance {hit.AttackType}, {hit.Source}, {hit.DamageDealt}, {hit.Multiplier} for {owner.name}");
            _dashDamage = 5 + PlayerData.instance.GetInt("nailSmithUpgrades") * 4;
            float multiplier = 1;

            if (PlayerData.instance.GetBool("hasShadowDash"))
            {
                multiplier *= 2;
            }
            if (PlayerData.instance.GetBool("equippedCharm_25"))
            {
                multiplier *= 1.5f;
            }
            if (PlayerData.instance.GetBool("equippedCharm_6") && PlayerData.instance.GetInt("health") == 1)
            {
                multiplier *= 1.75f;
            }
            if (_oldDashDamage != _dashDamage)
            {
                LogDebug($@"[Blackmoth] Sharp Shadow Damage set to {_dashDamage}");
                _oldDashDamage = _dashDamage;
            }
            if (hit.AttackType == AttackTypes.SharpShadow || hit.Source.name == "SuperDash Damage" && PlayerData.instance.GetBool("defeatedNightmareGrimm"))
            {
                LogDebug($@"Setting damage for {owner.name}");
                hit.DamageDealt         = _dashDamage;
                hit.AttackType          = 0;
                hit.Multiplier          = multiplier;
                hit.Direction           = HeroController.instance.cState.facingRight ? 0 : 180;
                hit.MagnitudeMultiplier = PlayerData.instance.GetBool("equippedCharm_15") ? 2f : 0f;
            }
            else if (hit.AttackType == AttackTypes.Nail)
            {
                LogDebug($@"Setting damage for {owner.name}");
                hit.DamageDealt = 1;
            }
            LogDebug($@"Creating HitInstance {hit.AttackType}, {hit.Source}, {hit.DamageDealt}, {hit.Multiplier} for 
            {owner.name}");
            orig(owner, hit);
        }
Exemplo n.º 53
0
    void Start()
    {
        //Auto Hooks
        currCheckpoint = GameObject.Find("startCP");
        player = FindObjectOfType<MasterController>();
        healthManager = FindObjectOfType<HealthManager>();
        respawnManager = FindObjectOfType<RespawnManager>();
        timerManager = FindObjectOfType<TimerManager>();

        //Game Data
        GameOptionData.currentLevel = Application.loadedLevel;

        //Camera Effects
        mainCamera = FindObjectOfType<Camera>();
        cameraSize = mainCamera.orthographicSize;
        zoomOutDuration = playerRespawnDelay * 0.35f;
        zoomInDuration = playerRespawnDelay;
        if(Application.loadedLevel == 7)
        {
            defaultCameraSize = 7.0f;
        }
        else
        {
            defaultCameraSize = mainCamera.orthographicSize;
        }

        cameraZoomInEffect = false;
        cameraZoomOutEffect = false;

        //Optional HUD Information
        //Enemy Count, XP Gems Remaining
        //levelXPGems = GameObject.FindGameObjectsWithTag("XP Gem");
        //arraySize = GameObject.FindObjectsOfType<EnemyHealthManager>().Length;
        //enemyPositionArray = new Vector3[arraySize];
    }
Exemplo n.º 54
0
    void Start()
    {
        // Cache references to scripts that utilise GameState variables
        pHealth = GameObject.Find ("Health Manager").GetComponent<HealthManager> ();
        healthHUD = GameObject.Find ("HUD_Healthbar").GetComponent<HUD_Healthbar> ();
        pInventory = GameObject.Find ("Inventory Manager").GetComponent<PlayerInventory> ();
        invHUD = GameObject.Find ("HUD_Inventory").GetComponent<HUD_Inventory> ();
        pTime = GameObject.Find("Time Manager").GetComponent<TimeScaler>();

        // Load game at the start of every scene
        LoadGame ();
    }
Exemplo n.º 55
0
 void Start()
 {
     sensing 		= 		GetComponent<GuardSensing> ();
     player 			= 		GameObject.FindWithTag("Player");
     torso 			= 		GameObject.Find ("ppl_chest");
     anim 			= 		GetComponent<Animator> ();
     pHealth 		= 		GameObject.Find ("Health Manager").GetComponent<HealthManager> ();
 }
Exemplo n.º 56
0
	void Awake () {
		Instance = this;
	}
Exemplo n.º 57
0
	// Use this for initialization
	void Start () {
        text = gameObject.GetComponent<Text>();
        hpManager = objectWithHP.GetComponent<HealthManager>();
        UpdateText();
	}
Exemplo n.º 58
0
    void Start()
    {
        player 			= 		GameObject.FindWithTag ("Player");
        navMeshAgent 	= 		GetComponent<NavMeshAgent> ();
        guardSensing 	= 		GetComponent<GuardSensing> ();
        guardAI 		= 		GetComponent<GuardAI> ();
        guardShooting 	= 		GetComponent<Shooting> ();
        anim 			= 		GetComponent<Animator> ();
        pHealth 		= 		GameObject.Find("Health Manager").GetComponent<HealthManager> ();
        guardBodyParts 	= 		GetComponent<GuardSelfDestruct> ();
        visionCone 		= 		transform.Find ("VisionCone").gameObject;

        // compile patrol and alert routes
        patrolRoute = new Vector3[4]
        {
            waypoint1.transform.position,
            waypoint2.transform.position,
            waypoint3.transform.position,
            waypoint2.transform.position
        };
        alertRoute = new Vector3[4]{
            alertWaypoint1.transform.position,
            alertWaypoint2.transform.position,
            alertWaypoint3.transform.position,
            alertWaypoint2.transform.position
        };
    }
Exemplo n.º 59
0
 // Use this for initialization
 void Start()
 {
     health = GetComponent<HealthManager>();
 }
 // Use this for initialization
 void Start()
 {
     animation = this.gameObject.GetComponent<Animation>();
     attackLength = animation.GetClip("Attack").length;
     playerHealthManager = player.GetComponent<HealthManager>();
 }