Exemplo n.º 1
0
	void HealthChangeCallback( HealthSystem health, float change )
	{
		if ( _health.alive )
		{
			_renderer.material.color = Color.Lerp( noHealthColor, fullHealthColor, _health.percent );
		}
	}
Exemplo n.º 2
0
    public void Start()
    {
        _ambassador = (Ambassador) FindObjectOfType(typeof(Ambassador));
        _control = GetComponent<PlayerControl>();
        _health = GetComponent<HealthSystem>();

        if(_ambassador == null
           || _control == null
           || _health == null)
        {
            if(DebugMode)
                Debug.LogWarning("Was unable to find player controls or ambassador!" + Environment.NewLine
                                 + "Ambassador: " + ((_ambassador == null) ? "Not Found" : "Found") + Environment.NewLine
                                 + "Player Controls: " + ((_control == null) ? "Not Found" : "Found") + Environment.NewLine
                                 + "Health System: " + ((_health == null) ? "Not Found" : "Found"));

            return;
        }

        _control.canOverthrust = _ambassador.HasItem(OverthrustSkill);
        _control.canUnderthrust = _ambassador.HasItem(UnderthrustSkill);
        _health.HP = _ambassador.MaxHP;
        _health.MaxHP = _ambassador.MaxHP;

        if(DebugMode)
            Debug.Log("Player " + (_control.canOverthrust ? "can" : "cannot") + " perform Overthrust." + Environment.NewLine
                      + "Player " + (_control.canUnderthrust ? "can" : "cannot") + " perform Underthrust."
                      + "Player's HP: " + _health.HP + "/" + _health.MaxHP);
    }
    public void Start()
    {
        _playerHealthSystem = GameObject.FindGameObjectWithTag("Player").GetComponent<HealthSystem>();
        _lastHP = _playerHealthSystem.HP;

        CalculateWidget();
    }
Exemplo n.º 4
0
 // Use this for initialization
 void Start()
 {
     hs = Camera.main.GetComponent<HarlemShake> ();
     thePlayer = GameObject.FindGameObjectWithTag ("Player");
     ah = thePlayer.GetComponent<AnimationHandler> ();
     playerHealthSystem = thePlayer.GetComponent<HealthSystem> ();
 }
Exemplo n.º 5
0
	// Use this for initialization
	void Start () {

		name = name.Replace ("(Clone)", "");

		HealthSystem = (HealthSystem)GetComponent (typeof(HealthSystem));

		HealthSystem.Death += AIDie;
		HealthSystem.Hit += AIHit;

		syncStartPosition = transform.position;
		syncEndPosition = transform.position;

		if(Network.isServer)
		{
			AIManager.Enemies ++;

			switch (AIType)
			{
				case AIBehaviourType.Melee:
					AddAction(new AILookForPlayer());
					AddAction(new AIWander());
					break;

			}

			seeker = (Seeker)GetComponent(typeof(Seeker));
			seeker.pathCallback += OnPathComplete;
		}
	}
Exemplo n.º 6
0
	void HealthCallback( HealthSystem minionHealth, float change )
	{
		if ( dropping && minionHealth.health <= 0 )
		{
			Drop();
		}
	}
Exemplo n.º 7
0
 // Use this for initialization
 void Start()
 {
     retryable = false;
     score = 0;
     hs = (HealthSystem) GameObject.FindGameObjectWithTag ("Player").GetComponent<HealthSystem>();
     gameOverMan = GameObject.FindGameObjectWithTag ("GameOverLayer");
     gameOverMan.SetActive (false);
 }
 // Use this for initialization
 void Start()
 {
     coll = (Collider2D)GetComponent(typeof(Collider2D));
     coll.enabled = false;
     playerMovement = (CharacterMovement)GameObject.Find("Player").GetComponent(typeof(CharacterMovement));
     playerHealth = (HealthSystem)GameObject.Find("Player").GetComponent(typeof(HealthSystem));
     anim = (Animator)GetComponent(typeof(Animator));
     timesSinceScream = timesSinceRightHand = timesSinceLeftHand = 1;
 }
Exemplo n.º 9
0
    public void Start()
    {
        health_bar = new HealthSystem(HealthBarDimens, VerticleHealthBar, HealthBubbleTexture, HealthTexture, HealthBubbleTextureRotation);
        exp_bar = new ExperienceSystem(ExpBarDimens, VerticleExpBar, ExpBubbleTexture, ExperienceTexture, ExpTextureRotation);
        mana_bar = new ManaSystem(ManaBarDimens, ManaBarScrollerDimens, VerticleManaBar, ManaBubbleTexture, ManaTexture, ManaBubbleTextureRotation);

        exp_bar.Initialize();
        health_bar.Initialize();
        mana_bar.Initialize();
    }
Exemplo n.º 10
0
 void OnTriggerEnter(Collider col)
 {
     if (currentEnemy == null) {
         if (col.gameObject.GetComponent<BattleScript>() != null) {
             this.currentEnemy = col.gameObject.GetComponent<HealthSystem>();
             currentEnemy.GetComponent<BattleScript>().attack(GetComponent<HealthSystem>());
             if(!isEnemy) {
                 currentEnemy.GetComponent<PathFinding>().stop();
             }
         }
     }
 }
Exemplo n.º 11
0
	void Awake()
	{
		transform = GetComponent<Transform>();

		_playerHealth = GetComponent<HealthSystem>();
		_playerWeapons = GetComponent<PlayerWeapons>();
		_plane = new Plane( Vector3.up, this.transform.position );

		// create a ray casting layer mask that collides with only "Scenery"
		_dashLayerMask = 1 << LayerMask.NameToLayer( "Scenery" );
		//_dashLayerMask = ~_dashLayerMask; // invert the mask
		_dashAvailable = true;
	}
Exemplo n.º 12
0
        public void TestUpdate()
        {
            var manager = new DemoEntityManager ();
            var entity = manager.CreateEntity ();
            entity.Tag = "A string tag";
            entity.AddComponent (new MoveComponent());
            entity.AddComponent (new HealthComponent(10));

            var system = new HealthSystem (manager);
            system.Update (0f);
            var healthComponent = entity.GetFirstComponentOfType<HealthComponent>() as HealthComponent;
            healthComponent.CurrentHealthPoints = -1;
            system.Update (1f);
            Assert.IsFalse (healthComponent.IsAlive, "Updating health system failed.");
        }
Exemplo n.º 13
0
	void Awake()
	{
		_perks = new Dictionary<PerkType, PerkData>();
		_perkEnding = new Dictionary<PerkType, Coroutine>();

		for ( int i = 0; i < startingPerks.Length; i++ )
		{
			AddPerk( startingPerks[i] );
		}

		_playerSpeed = GetComponent<PlayerMovement>();
		_playerHealth = GetComponent<HealthSystem>();
		_playerWeapons = GetComponent<PlayerWeapons>();

		shield.GetComponent<DeathSystem>().RegisterDeathCallback( PlayerShieldDestroyed );
	}
Exemplo n.º 14
0
	void Awake()
	{
		// retrieve all states
		basicState = GetComponent<SpiderTankBasicState>();
		fleeState = GetComponent<SpiderTankFleeState>();
		healState = GetComponent<SpiderTankHealState>();
		laserSpin = GetComponent<SpiderTankLaserSpin>();
		rushState = GetComponent<SpiderTankRushState>();
		turboState = GetComponent<SpiderTankTurboState>();
		enterState = GetComponent<SpiderTankEnterState>();

		// retrieve other componenets
		health = GetComponent<HealthSystem>();
		spawner = GetComponent<EnemySpawner>();
		agent = GetComponent<NavMeshAgent>();
		boxCollider = GetComponent<BoxCollider>();
		ringUICanvas = GetComponentInChildren<Canvas>();
		meshes = GetComponentsInChildren<MeshRenderer>();
		animator = GetComponentInChildren<Animator>();

		// register for player death callback
		player.gameObject.GetComponent<DeathSystem>().RegisterDeathCallback( PlayerDeathCallback );

		// register for damage callbacks
		health.RegisterHealthCallback( SpiderDamageCallback );
		healthCheckpoints.currentPhase = 0;

		// set hand player over as the target to a bunch of script
		KeepDistance keepDistance = GetComponent<KeepDistance>();
		if ( keepDistance != null )
		{
			keepDistance.target = player;
		}
		mortarLauncher.mortarSettings.targets = new Transform[1];
		mortarLauncher.mortarSettings.targets[0] = player;
		spawnerLauncher.spiderTank = this;

		spawner.settings = phaseSettings[0].spawnerSettings;

		_healthMaxStart = health.maxHealth;
		_healthMaxCurr = _healthMaxStart;
	}
Exemplo n.º 15
0
    public bool shoot(GameObject attacker, GameObject target)
    {
        healthSystem = GameObject.Find("Manager").GetComponent<HealthSystem>();

        currentplayerAttr = (AttributeComponent)attacker.GetComponent(typeof(AttributeComponent));
        currentPlayerCell = currentplayerAttr.getCurrentCell();
        currentPlayerWeapon = (WeaponComponent)currentplayerAttr.weapon.GetComponent(typeof(WeaponComponent));
        if(attacker.tag == "FigurSpieler1")
            currentPlayerComp = GameObject.Find("Player1").GetComponent<PlayerComponent>();
        else
            currentPlayerComp = GameObject.Find("Player2").GetComponent<PlayerComponent>();

        currentTargetAttr = (AttributeComponent)target.GetComponent(typeof(AttributeComponent));
        currentTargetCell = currentTargetAttr.getCurrentCell();

        distanceBetweenPlayers = Vector3.Magnitude(currentTargetCell.transform.position - currentPlayerCell.transform.position);
        Debug.Log("Distance between players is " + distanceBetweenPlayers);

        if (playerCanShoot())
        {
            float hitChance = chanceOfHittingTarget();
            Debug.Log("Hitchance: " + hitChance);
            if (hitChance >= Random.value)
            {
                if (healthSystem == null)
                    Debug.Log("Healthsys");
                if (currentplayerAttr == null)
                    Debug.Log("currentplayerAttr");
                if (currentPlayerComp == null)
                    Debug.Log("currentPlayerComp");
                if (currentTargetAttr == null)
                    Debug.Log("currentTargetAttr");
                healthSystem.doDamage(currentplayerAttr, currentPlayerComp, currentTargetAttr, HealthSystem.SHOOT);
                return true;
            }
            else
            {
                return false;
            }
        }
        return false;
    }
Exemplo n.º 16
0
	// Use this for initialization
	void Awake()
	{
		GetComponent<DeathSystem>().RegisterDeathCallback( DeathCallback );
		minionHealth = GetComponent<HealthSystem>();
		minionHealth.RegisterHealthCallback( HealthCallback );
	}
Exemplo n.º 17
0
	public void HealthTriggerCallback( HealthSystem health )
	{
		CancelInvoke();
		enabled = false;
		spiderTank.fleeState.enabled = true;
	}
Exemplo n.º 18
0
 // Start is called before the first frame update
 void Start()
 {
     m_healthSystem = new HealthSystem(100);
     m_healthBar.Setup(m_healthSystem);
 }
Exemplo n.º 19
0
 // Start is called before the first frame update
 void Start()
 {
     healthSystem = GameObject.FindGameObjectWithTag("HealthSystem").GetComponent <HealthSystem>();
 }
Exemplo n.º 20
0
	protected virtual void SetupEntity()
	{
		health = GetComponent<HealthSystem> ();
		syncStartPosition = transform.position;
		syncEndPosition = transform.position;
	}
Exemplo n.º 21
0
 // Called when funciton is initialized
 void Awake()
 {
     health = new HealthSystem();
 }
Exemplo n.º 22
0
	public virtual void Update(HealthSystem sys){}
Exemplo n.º 23
0
	void SpiderDamageCallback( HealthSystem health, float damage )
	{
		if ( health.health < _healthTrigger )
		{
			_healthTriggerCallback( health );
		}

		int currentPhase = healthCheckpoints.currentPhase;
		if ( currentPhase < healthCheckpoints.phaseHealthPercents.Length - 1 )
		{
			float healthCheckpoint = healthCheckpoints.phaseHealthPercents[currentPhase + 1];
			if ( (health.percent * 100.0f) <= healthCheckpoint )
			{
				healthCheckpoints.currentPhase++;
				_healthMaxCurr = _healthMaxStart * healthCheckpoint * 0.01f;
				spawner.settings = phaseSettings[healthCheckpoints.currentPhase].spawnerSettings;
			}
		}
	}
Exemplo n.º 24
0
 private void Awake()
 {
     unitList.Add(this);
     health = new HealthSystem(100);
 }
Exemplo n.º 25
0
 // Use this for initialization
 void Awake()
 {
     GetComponent <DeathSystem>().RegisterDeathCallback(DeathCallback);
     minionHealth = GetComponent <HealthSystem>();
     minionHealth.RegisterHealthCallback(HealthCallback);
 }
Exemplo n.º 26
0
 public void Setup(HealthSystem healthSystem)
 {
     this.healthSystem = healthSystem;
 }
Exemplo n.º 27
0
 void Start()
 {
     health = new HealthSystem();
     health.setHealth(100);
     endBoss = GameObject.Find("EndBoss");
 }
Exemplo n.º 28
0
 private void Awake()
 {
     playerHealthSystem = GameUtility.Player.GetComponent <HealthSystem>();
 }
Exemplo n.º 29
0
 public override void Use(HealthSystem hs)
 {
     DealDamage(hs);
     PlayParticleEffect();
     PlayAbilitySound();
 }
Exemplo n.º 30
0
 private void DealDamage(HealthSystem hs)
 {
     hs.TakeDamage((config as PowerAttackConfig).GetExtraDamage());
 }
Exemplo n.º 31
0
    // Use this for initialization
    void Start()
    {
        startPosition = transform.position;
        nextTurnPoint = transform.position;
        attacking = false;
        returningToSpawnPoint = false;
        currentSpeed = fishSpeed;
        thePlayer = GameObject.FindGameObjectWithTag ("Player");
        healthSystem = GetComponent<HealthSystem> ();
        playerAnimation = thePlayer.GetComponent<AnimationHandler> ();

        randomDirection ();
    }
Exemplo n.º 32
0
    void Start()
    {
        transform.FindChild("SelectedIndicator").gameObject.SetActive(false);
        transform.FindChild("SelectedIndicator").renderer.material.SetColor("_Color", new Color(ActiveColor.r + (ActiveColor.r / 2), ActiveColor.g + (ActiveColor.g / 2), ActiveColor.b + (ActiveColor.b / 2)));
        transform.FindChild("SelectedIndicator").renderer.material.SetColor("_Emission", ActiveColor);
        transform.FindChild("SelectedIndicator").localScale = new Vector3(.1f + transform.localScale.x * .03f, 1, .1f + transform.localScale.z * .03f);

        control_handlers.Add(this.transform);

        healthSystem = new HealthSystem(HealthBarDimens, VerticleHealthBar, HealthBubbleTexture, HealthTexture, BarRotationVal);
        healthSystem.Initialize();
    }
Exemplo n.º 33
0
 void Awake()
 {
     level = new LevelSystem ();
     level.character = this;
     health = new HealthSystem ();
 }
Exemplo n.º 34
0
    /// <summary>
    /// The RPC for the shooting, called from the event on the networking player (called from Shoot())
    /// </summary>
    /// <param name="args"></param>
    private void RPCShoot(RpcArgs args)
    {
        //If there are bullets left in the clip and the player is not reloading
        if (currentWeapon.bulletsPerClip > 0 && !isReloading)
        {
            //Shoot!
            //Decrement the clipsize
            currentWeapon.bulletsPerClip--;

            Vector3 origin     = args.GetNext <Vector3>();
            Vector3 camForward = args.GetNext <Vector3>();

            //Only make the server do the actual shooting
            if (np.networkObject.IsServer)
            {
                RaycastHit hit;
                Debug.DrawRay(origin, camForward * 10000, Color.black, 10);
                //Do the actual raycast on the server
                if (Physics.Raycast(origin, camForward, out hit, 10000, raycastIncludeMask))
                {
                    //If the current weapon doesn't use projectiles
                    if (currentWeapon.hitscan)
                    {
                        HealthSystem enemyHP = hit.collider.GetComponent <HealthSystem>();
                        if (enemyHP)
                        {
                            //call take damage and supply some raycast hit information
                            enemyHP.TakeDamage(currentWeapon.damagePerShot, setupPlayer.PlayerName, hit.point, hit.normal);
                        }
                    }
                }
            }

            //If it's not a hitscan weapon, use projectiles. Checking for collisions on the projectiles themselves is too unstable and unreliable
            //So raycast and set the raycast hit point to the target of the projectile
            if (!currentWeapon.hitscan)
            {
                RaycastHit hit;
                GameObject projectile = GameObject.Instantiate(currentWeapon.projectile, currentWeapon.worldModelMuzzlePoint.transform.position, currentWeapon.worldModelMuzzlePoint.transform.rotation);
                // Get the projectile and set the damage
                BaseProjectile p = projectile.GetComponent <BaseProjectile>();
                //Setup the damage on the projectile, but only on the server
                ///if (np.networkObject.IsServer)
                if (NetworkManager.Instance.IsMaster)
                {
                    p.damage       = currentWeapon.damagePerShot;
                    p.attackerName = setupPlayer.PlayerName;
                }

                //Do the raycast and set the target on the projectile to what the raycast hit, along the hit normal (used for bloodsplatter direction)
                if (Physics.Raycast(currentWeapon.viewModelMuzzlePoint.transform.position, camForward, out hit, 10000))
                {
                    p.target    = hit.point;
                    p.hitNormal = hit.normal;
                }
                else //If raycast didn't hit anything
                {
                    //just make the target in the direction, lifetime will kill this projectile
                    p.target = (currentWeapon.viewModelMuzzlePoint.transform.position + camForward) * 1000;
                    //No hit normal as it's unusual that this hits anything at all (Fired outside of map)
                }
            }

            //Play the animation
            worldModelAnimator.SetTrigger("shoot");

            //If we aren't the owner of the object (think local player), do the world model muzzleflash
            ///if (!np.networkObject.IsOwner)
            if (np.networkObject.IsRemote)
            {
                //If the corountine is already running, stop it.
                if (worldModelMuzzleFlashCorountine != null)
                {
                    StopCoroutine(worldModelMuzzleFlashCorountine);
                }
                //Start the muzzle flash corountine
                worldModelMuzzleFlashCorountine = StartCoroutine(ShowWorldModelMuzzle(currentWeapon.worldModelMuzzlePoint.transform.position));
            }
        }

        //if the clipsize is 0, autoreload is true, and we are not reloading, then, auto reload
        if (currentWeapon.bulletsPerClip == 0 && autoReload && !isReloading)
        {
            if (currentWeapon.clips <= 0)
            {
                Debug.Log("Out of ammo");
            }
            else
            {
                Reload();
            }
        }
    }
Exemplo n.º 35
0
 // Use this for initialization
 void Awake()
 {
     ms = (ManagerSystem) GameObject.Find("Manager").GetComponent(typeof(ManagerSystem));
     hs = (HealthSystem) GameObject.Find("Manager").GetComponent(typeof(HealthSystem));
 }
Exemplo n.º 36
0
 // Start is called before the first frame update
 void Start()
 {
     healthSystem = GameObject.FindGameObjectWithTag("HealthSystem").GetComponent <HealthSystem>();
     StartCoroutine(SpawnRandomAnimalCoroutine());
     //InvokeRepeating("SpawnRandomAnimal", startDelay, spawnInterval);
 }
Exemplo n.º 37
0
 public void Init(HealthSystem healthSystem)
 {
     _healthSystem = healthSystem;
     _healthSystem.OnHealthChanged += HealthSystemOnOnHealthChanged;
     healthValueInfo.text           = _healthSystem.MaxHealth + "/" + _healthSystem.MaxHealth;
 }
Exemplo n.º 38
0
 private void Start()
 {
     HealthSystemScript = GameObject.FindGameObjectWithTag("HealthSystem").GetComponent <HealthSystem>();
 }
Exemplo n.º 39
0
 private void Awake()
 {
     HealthSystem  = new HealthSystem(_turretData.MaxHealth);
     _defaultColor = _spriteDamageIndicator.color;
 }
Exemplo n.º 40
0
 public void ChangeHealth(IDamageDealer changer, double damage) => HealthSystem.ChangeHealth(changer, damage);
Exemplo n.º 41
0
    public void SetUp(HealthSystem healthSystem)
    {
        this.healthSystem = healthSystem;

        healthSystem.OnHealthChanged += HealthSystem_OnHealthChanged;
    }
Exemplo n.º 42
0
    /// <summary>
    /// Reads the prototype furniture from XML.
    /// </summary>
    /// <param name="readerParent">The XML reader to read from.</param>
    public void ReadXmlPrototype(XmlReader readerParent)
    {
        Type = readerParent.GetAttribute("type");

        XmlReader reader = readerParent.ReadSubtree();

        while (reader.Read())
        {
            switch (reader.Name)
            {
            case "TypeTag":
                reader.Read();
                typeTags.Add(reader.ReadContentAsString());
                break;

            case "MovementCost":
                reader.Read();
                MovementCost = reader.ReadContentAsFloat();
                break;

            case "PathfindingModifier":
                reader.Read();
                PathfindingModifier = reader.ReadContentAsFloat();
                break;

            case "PathfindingWeight":
                reader.Read();
                PathfindingWeight = reader.ReadContentAsFloat();
                break;

            case "Width":
                reader.Read();
                Width = reader.ReadContentAsInt();
                break;

            case "Height":
                reader.Read();
                Height = reader.ReadContentAsInt();
                break;

            case "Health":
                reader.Read();
                health = new HealthSystem(reader.ReadContentAsFloat(), false, true, false, false);
                break;

            case "LinksToNeighbours":
                reader.Read();
                LinksToNeighbour = reader.ReadContentAsString();
                break;

            case "EnclosesRooms":
                reader.Read();
                RoomEnclosure = reader.ReadContentAsBoolean();
                break;

            case "CanReplaceFurniture":
                replaceableFurniture.Add(reader.GetAttribute("typeTag").ToString());
                break;

            case "CanRotate":
                reader.Read();
                CanRotate = reader.ReadContentAsBoolean();
                break;

            case "DragType":
                reader.Read();
                DragType = reader.ReadContentAsString();
                break;

            case "CanBeBuiltOn":
                tileTypeBuildPermissions.Add(reader.GetAttribute("tileType"));
                break;

            case "Animations":
                XmlReader animationReader = reader.ReadSubtree();
                ReadAnimationXml(animationReader);
                break;

            case "Action":
                XmlReader subtree = reader.ReadSubtree();
                EventActions.ReadXml(subtree);
                subtree.Close();
                break;

            case "ContextMenuAction":
                contextMenuLuaActions.Add(new ContextMenuLuaAction
                {
                    LuaFunction              = reader.GetAttribute("FunctionName"),
                    LocalizationKey          = reader.GetAttribute("LocalizationKey"),
                    RequireCharacterSelected = bool.Parse(reader.GetAttribute("RequireCharacterSelected")),
                    DevModeOnly              = bool.Parse(reader.GetAttribute("DevModeOnly") ?? "false")
                });
                break;

            case "IsEnterable":
                isEnterableAction = reader.GetAttribute("FunctionName");
                break;

            case "GetProgressInfo":
                getProgressInfoNameAction = reader.GetAttribute("functionName");
                break;

            case "JobWorkSpotOffset":
                Jobs.ReadWorkSpotOffset(reader);
                break;

            case "JobInputSpotOffset":
                Jobs.ReadInputSpotOffset(reader);
                break;

            case "JobOutputSpotOffset":
                Jobs.ReadOutputSpotOffset(reader);
                break;

            case "Params":
                ReadXmlParams(reader);      // Read in the Param tag
                break;

            case "LocalizationCode":
                reader.Read();
                LocalizationCode = reader.ReadContentAsString();
                break;

            case "UnlocalizedDescription":
                reader.Read();
                UnlocalizedDescription = reader.ReadContentAsString();
                break;

            case "Component":
                BuildableComponent component = BuildableComponent.Deserialize(reader);
                if (component != null)
                {
                    component.InitializePrototype(this);
                    components.Add(component);
                }

                break;

            case "OrderAction":
                OrderAction orderAction = OrderAction.Deserialize(reader);
                if (orderAction != null)
                {
                    orderActions[orderAction.Type] = orderAction;
                }

                break;
            }
        }

        if (orderActions.ContainsKey("Uninstall"))
        {
            InventoryCommon asInventory = new InventoryCommon();
            asInventory.type         = Type;
            asInventory.maxStackSize = 1;
            asInventory.basePrice    = 0f;
            asInventory.category     = "crated_furniture";
            PrototypeManager.Inventory.Add(asInventory);
        }
    }
Exemplo n.º 43
0
    // Use this for initialization
    void Start()
    {
        Stamina_bar = new HealthSystem(StaminaBarDimens, VerticleStaminaBar, StaminaBubbleTexture, StaminaTexture, StaminaBubbleTextureRotation);

        Stamina_bar.Initialize(maxValue);
    }
Exemplo n.º 44
0
    /// <summary>
    /// Copy Constructor -- don't call this directly, unless we never
    /// do ANY sub-classing. Instead use Clone(), which is more virtual.
    /// </summary>
    private Furniture(Furniture other)
    {
        Type                = other.Type;
        typeTags            = new HashSet <string>(other.typeTags);
        MovementCost        = other.MovementCost;
        PathfindingModifier = other.PathfindingModifier;
        PathfindingWeight   = other.PathfindingWeight;
        RoomEnclosure       = other.RoomEnclosure;
        Width               = other.Width;
        Height              = other.Height;
        CanRotate           = other.CanRotate;
        Rotation            = other.Rotation;
        Tint                = other.Tint;
        LinksToNeighbour    = other.LinksToNeighbour;
        health              = other.health;

        Parameters = new Parameter(other.Parameters);
        Jobs       = new BuildableJobs(this, other.Jobs);

        // add cloned components
        components = new HashSet <BuildableComponent>();
        foreach (BuildableComponent component in other.components)
        {
            components.Add(component.Clone());
        }

        // add cloned order actions
        orderActions = new Dictionary <string, OrderAction>();
        foreach (var orderAction in other.orderActions)
        {
            orderActions.Add(orderAction.Key, orderAction.Value.Clone());
        }

        if (other.Animation != null)
        {
            Animation = other.Animation.Clone();
        }

        if (other.EventActions != null)
        {
            EventActions = other.EventActions.Clone();
        }

        if (other.contextMenuLuaActions != null)
        {
            contextMenuLuaActions = new List <ContextMenuLuaAction>(other.contextMenuLuaActions);
        }

        if (other.ReplaceableFurniture != null)
        {
            replaceableFurniture = other.ReplaceableFurniture;
        }

        isEnterableAction = other.isEnterableAction;

        getProgressInfoNameAction = other.getProgressInfoNameAction;

        tileTypeBuildPermissions = new HashSet <string>(other.tileTypeBuildPermissions);

        RequiresSlowUpdate = EventActions.HasEvent("OnUpdate") || components.Any(c => c.RequiresSlowUpdate);

        RequiresFastUpdate = EventActions.HasEvent("OnFastUpdate") || components.Any(c => c.RequiresFastUpdate);

        LocalizationCode       = other.LocalizationCode;
        UnlocalizedDescription = other.UnlocalizedDescription;

        // force true as default, to trigger OnIsOperatingChange (to sync the furniture icons after initialization)
        IsOperating = true;
    }
Exemplo n.º 45
0
	private void TargetDamageCallback( HealthSystem playerHealth, float healthChange )
	{
		if ( healthChange < 0.0f )
		{
			_camShake.Shake( healthChange );
			_rumbler.Rumble( healthChange );
		}
	}
Exemplo n.º 46
0
        public void Can_Create()
        {
            HealthSystem hs = CreateDefaultHealthSystem();

            Assert.IsNotNull(hs);
        }
Exemplo n.º 47
0
	void HealthCallback( HealthSystem healthSystem, float healthChange )
	{
		healthDisplay.fillAmount = healthSystem.percent;
	}
Exemplo n.º 48
0
 void Start()
 {
     _health = GetComponent <HealthSystem>();
 }
Exemplo n.º 49
0
	public override void Update (HealthSystem sys)
	{
		if(Time.time - lastBleed > 1.5f)
		{
			EffectManager.CreateEffect(sys.transform.position, "Blood Drop 1");
			lastBleed = Time.time;
		}
	}
Exemplo n.º 50
0
    //Unit was hit
    public void Hit(DamageObject d)
    {
        if (HitableStates.Contains(enemyState))
        {
            //only allow ground attacks to hit us when we are knocked down
            if (enemyState == UNITSTATE.KNOCKDOWNGROUNDED && !d.isGroundAttack)
            {
                return;
            }

            CancelInvoke();
            StopAllCoroutines();
            animator.StopAllCoroutines();
            Move(Vector3.zero, 0f);

            //add attack time out so this enemy cannot attack instantly after a hit
            lastAttackTime = Time.time;

            //don't hit this unit when it's allready down
            if ((enemyState == UNITSTATE.KNOCKDOWNGROUNDED || enemyState == UNITSTATE.GROUNDHIT) && !d.isGroundAttack)
            {
                return;
            }

            //defend an incoming attack
            if (!d.DefenceOverride && defendableStates.Contains(enemyState))
            {
                int rand = Random.Range(0, 100);
                if (rand < defendChance)
                {
                    Defend();
                    return;
                }
            }

            //hit sfx
            GlobalAudioPlayer.PlaySFXAtPosition(d.hitSFX, transform.position);

            //hit particle effect
            ShowHitEffectAtPosition(new Vector3(transform.position.x, d.inflictor.transform.position.y + d.collHeight, transform.position.z));

            //camera Shake
            CamShake camShake = Camera.main.GetComponent <CamShake>();
            if (camShake != null)
            {
                camShake.Shake(.1f);
            }

            //activate slow motion camera
            if (d.slowMotionEffect)
            {
                CamSlowMotionDelay cmd = Camera.main.GetComponent <CamSlowMotionDelay>();
                if (cmd != null)
                {
                    cmd.StartSlowMotionDelay(.2f);
                }
            }

            //substract health
            HealthSystem hs = GetComponent <HealthSystem>();
            if (hs != null)
            {
                hs.SubstractHealth(d.damage);
                if (hs.CurrentHp == 0)
                {
                    return;
                }
            }

            //ground attack
            if (enemyState == UNITSTATE.KNOCKDOWNGROUNDED)
            {
                StopAllCoroutines();
                enemyState = UNITSTATE.GROUNDHIT;
                StartCoroutine(GroundHit());
                return;
            }

            //turn towards the direction of the incoming attack
            int dir = d.inflictor.transform.position.x > transform.position.x ? 1 : -1;
            TurnToDir((DIRECTION)dir);

            //check for a knockdown
            if (d.knockDown)
            {
                StartCoroutine(KnockDownSequence(d.inflictor));
                return;
            }
            else
            {
                //default hit
                int rand = Random.Range(1, 3);
                animator.SetAnimatorTrigger("Hit" + rand);
                enemyState = UNITSTATE.HIT;

                //add small force from the impact
                LookAtTarget(d.inflictor.transform);
                animator.AddForce(-KnockbackForce);

                //switch  enemy state from passive to aggressive when attacked
                if (enemyTactic != ENEMYTACTIC.ENGAGE)
                {
                    EnemyManager.setAgressive(gameObject);
                }

                Invoke("Ready", hitRecoveryTime);
                return;
            }
        }
    }
Exemplo n.º 51
0
    void SetupHealth(GameObject aHealthUI)
    {
        HealthSystem healthSystem = aHealthUI.GetComponentInChildren <HealthSystem> ();

        healthSystem.m_PlayerStat = m_Character.GetComponent <PlayerStat> ();
    }
Exemplo n.º 52
0
    public override void OnInspectorGUI()
    {
        HealthSystem script = (HealthSystem)target;

        //bool dirty = false;



        //Health Values
        EditorGUILayout.LabelField("Health");
        EditorGUILayout.BeginHorizontal();
        {
            script.Health    = EditorGUILayout.IntField(script.Health);
            script.HealthMax = EditorGUILayout.IntField(script.HealthMax);
        }
        EditorGUILayout.EndHorizontal();
        script.HealthRegenerates = EditorGUILayout.Toggle("Health Regens? ", script.HealthRegenerates);

        //Hunger
        script.HungerEnabled = EditorGUILayout.Toggle("Hunger", script.HungerEnabled);
        if (script.HungerEnabled)
        {
            EditorGUILayout.BeginHorizontal();
            {
                script.Hunger    = EditorGUILayout.IntField(script.Hunger);
                script.HungerMax = EditorGUILayout.IntField(script.HungerMax);
            }
            EditorGUILayout.EndHorizontal();
        }

        //Stamina
        script.StaminaEnabled = EditorGUILayout.Toggle("Stamina Enabled", script.StaminaEnabled);
        if (script.StaminaEnabled)
        {
            EditorGUILayout.BeginHorizontal();
            {
                script.Stamina    = EditorGUILayout.IntField(script.Stamina);
                script.StaminaMax = EditorGUILayout.IntField(script.StaminaMax);
            }
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.Separator();
        hitEffectsToggle = EditorGUILayout.Foldout(hitEffectsToggle, "Hit Effects");
        if (hitEffectsToggle)
        {
            List <GameObject> hitEffects = new List <GameObject>();
            hitEffects.AddRange(script.HitEffects);
            int delete = -1;

            for (int i = 0; i < hitEffects.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();
                hitEffects[i] = (GameObject)EditorGUILayout.ObjectField(hitEffects[i], typeof(GameObject), false);
                if (GUILayout.Button("Remove"))
                {
                    delete = i;
                }


                EditorGUILayout.EndHorizontal();
            }
            if (delete > -1)
            {
                hitEffects.RemoveAt(delete);
            }


            if (GUILayout.Button("Add"))
            {
                hitEffects.Add(null);
            }

            script.HitEffects = hitEffects.ToArray();
        }

        EditorGUILayout.Separator();
        hitDropToggle = EditorGUILayout.Foldout(hitDropToggle, "Hit Drop Effects");
        if (hitDropToggle)
        {
            List <GameObject> hitDrops = new List <GameObject>(script.HitDropEffects);
            int delete = -1;

            for (int i = 0; i < hitDrops.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();
                hitDrops[i] = (GameObject)EditorGUILayout.ObjectField(hitDrops[i], typeof(GameObject), false);
                if (GUILayout.Button("Remove"))
                {
                    delete = i;
                }


                EditorGUILayout.EndHorizontal();
            }
            if (delete > -1)
            {
                hitDrops.RemoveAt(delete);
            }


            if (GUILayout.Button("Add"))
            {
                hitDrops.Add(null);
            }

            script.HitDropEffects = hitDrops.ToArray();
        }


        EditorGUILayout.Separator();

        if (GUILayout.Button("Save"))
        {
            EditorUtility.SetDirty(script);
        }
    }
Exemplo n.º 53
0
	void Awake()
	{
		_renderer = renderer;
		_health = GetComponent<HealthSystem>();
		_health.RegisterHealthCallback( HealthChangeCallback );
	}
Exemplo n.º 54
0
 private void Awake()
 {
     _healthSystem = GetComponent <HealthSystem>();
 }
Exemplo n.º 55
0
	public void UpdateHealthBar( HealthSystem healthSystem, float healthChange )
	{
		indicatorImage.fillAmount = healthSystem.percent;
	}
Exemplo n.º 56
0
    public void AddTarget(Collider2D target)
    {
        HealthSystem targetHealth = target.GetComponentInParent <HealthSystem>();

        Targets.Add(targetHealth);
    }
Exemplo n.º 57
0
	// Use this for initialization
	void Start () {
		health = GetComponent<HealthSystem> ();
		health.Death += OnDeath;
	}
Exemplo n.º 58
0
    public void RemoveTarget(Collider2D target)
    {
        HealthSystem targetHealth = target.GetComponentInParent <HealthSystem>();

        Targets.Remove(targetHealth);
    }
Exemplo n.º 59
0
    // Use this for initialization
    void Start()
    {
        theGridSystem     = GameObject.Find("PlayerTetrisGrid").GetComponent <GridSystem>();
        enemyGridSystem   = GameObject.Find("EnemyTetrisGrid").GetComponent <enemyGridSystem>();
        thePowerupsSystem = GameObject.Find("PowerUpSystem").GetComponent <PowerupsSystem>();
        if (!enemyGridSystem.multi)
        {
            theTrapSystem = GameObject.Find("TrapSystem").GetComponent <TrapSystem>();
        }


        thePlayer = GameObject.Find("Player");
        game      = GameObject.Find("EventSystem").GetComponent <GameCode>();

        health = this.gameObject.AddComponent <HealthSystem>();

        attackHeight     = 40;
        originPos        = transform.position;
        Pos              = originPos;
        canvasLocalScale = GameObject.FindGameObjectWithTag("Canvas").transform.localScale;


        //Attack adjacent tiles
        attackWidth = 150;



        //Debug.Log("Cavalry");
        if (type == "Cavalry")
        {
            health.InitHealth(PlayerPrefs.GetFloat("calvaryHP"));
            attckDmg = PlayerPrefs.GetFloat("calvaryAtt");
            attckSpd = PlayerPrefs.GetFloat("calvaryAttSpd");
            speed    = PlayerPrefs.GetFloat("calvarySpd");

            vision = 100;
            range  = 100;
            state  = (int)States.CHARGE;
            //prevhealth = health;
            activ  = true;
            _class = 3;
            if (terrainName == "Hills")
            {
                attckDmg = (attckDmg * game.TMV_Cavalry.attackDamage);
                speed    = (speed * game.TMV_Cavalry.speed);
                attckSpd = (attckSpd * game.TMV_Cavalry.attackSpeed);
            }
            else if (terrainName == "Forest")
            {
                attckDmg = (attckDmg * game.TMV_Cavalry.attackDamage);
                speed    = (speed * game.TMV_Cavalry.speed);
                attckSpd = (attckSpd * game.TMV_Cavalry.attackSpeed);
            }
            else if (terrainName == "River")
            {
                attckDmg = (attckDmg * game.TMV_Cavalry.attackDamage);
                speed    = (speed * game.TMV_Cavalry.speed);
                attckSpd = (attckSpd * game.TMV_Cavalry.attackSpeed);
            }
            else if (terrainName == "Plains")
            {
                attckDmg = (attckDmg * game.TMV_Cavalry.attackDamage);
                speed    = (speed * game.TMV_Cavalry.speed);
                attckSpd = (attckSpd * game.TMV_Cavalry.attackSpeed);
            }
        }
        else if (type == "Infantry")
        {
            // Debug.Log("Infantry");
            health.InitHealth(PlayerPrefs.GetFloat("infantryHP"));
            attckDmg = PlayerPrefs.GetFloat("infantryAtt", attckDmg);
            attckSpd = PlayerPrefs.GetFloat("infantryAttSpd");
            speed    = PlayerPrefs.GetFloat("infantrySpd");
            range    = 100;

            vision = 100;
            state  = (int)States.CHARGE;
            //prevhealth = health;
            activ  = true;
            _class = 1;
            if (terrainName == "Hills")
            {
                attckDmg = (attckDmg * game.TMV_Infantry.attackDamage);
                speed    = (speed * game.TMV_Infantry.speed);
                attckSpd = (attckSpd * game.TMV_Infantry.attackSpeed);
            }
            else if (terrainName == "Forest")
            {
                attckDmg = (attckDmg * game.TMV_Infantry.attackDamage);
                speed    = (speed * game.TMV_Infantry.speed);
                attckSpd = (attckSpd * game.TMV_Infantry.attackSpeed);
            }
            else if (terrainName == "River")
            {
                attckDmg = (attckDmg * game.TMV_Infantry.attackDamage);
                speed    = (speed * game.TMV_Infantry.speed);
                attckSpd = (attckSpd * game.TMV_Infantry.attackSpeed);
            }
            else if (terrainName == "Plains")
            {
                attckDmg = (attckDmg * game.TMV_Infantry.attackDamage);
                speed    = (speed * game.TMV_Infantry.speed);
                attckSpd = (attckSpd * game.TMV_Infantry.attackSpeed);
            }
        }
        else if (type == "Bowmen")
        {
            // Debug.Log("Bowmen");
            health.InitHealth(PlayerPrefs.GetFloat("bowmenHP"));
            attckDmg      = PlayerPrefs.GetFloat("bowmenAtt", attckDmg);
            attckSpd      = PlayerPrefs.GetFloat("bowmenAttSpd");
            speed         = PlayerPrefs.GetFloat("bowmenSpd");
            theProjectile = GetComponent <Projectile>();
            range         = 300;
            vision        = 300;
            state         = (int)States.CHARGE;
            //prevhealth = health;
            activ  = true;
            _class = 2;
            if (terrainName == "Hills")
            {
                attckDmg = (attckDmg * game.TMV_Bowmen.attackDamage);
                speed    = (speed * game.TMV_Bowmen.speed);
                attckSpd = (attckSpd * game.TMV_Bowmen.attackSpeed);
            }
            else if (terrainName == "Forest")
            {
                attckDmg = (attckDmg * game.TMV_Bowmen.attackDamage);
                speed    = (speed * game.TMV_Bowmen.speed);
                attckSpd = (attckSpd * game.TMV_Bowmen.attackSpeed);
            }
            else if (terrainName == "River")
            {
                attckDmg = (attckDmg * game.TMV_Bowmen.attackDamage);
                speed    = (speed * game.TMV_Bowmen.speed);
                attckSpd = (attckSpd * game.TMV_Bowmen.attackSpeed);
            }
            else if (terrainName == "Plains")
            {
                attckDmg = (attckDmg * game.TMV_Bowmen.attackDamage);
                speed    = (speed * game.TMV_Bowmen.speed);
                attckSpd = (attckSpd * game.TMV_Bowmen.attackSpeed);
            }
        }
        //Debug.Log(transform.position
    }
Exemplo n.º 60
0
 void Start()
 {
     FiringAllowed = true;
     health        = gameObject.GetComponent <HealthSystem>();
 }