Inheritance: MonoBehaviour
Exemplo n.º 1
0
	//For a kill volume the player or enemy only has to collide once with it
	void OnTriggerEnter2D (Collider2D collider)
	{

		//Initialize HealthController
		healthController = collider.gameObject.GetComponent<HealthController>();
		
		//If the collider has a healthController
		if (healthController != null)
		{
			//Check if collider = player and onlyHurtPlayer or if it is notHurtPlayer
			if ((collider.gameObject.tag == "Player" && onlyHurtPlayer) || !onlyHurtPlayer) 	
			{
				if (startEnabled)
				{
					//Check if the player is invulnerable, otherwise don't hurt him
					if (!healthController.isInvulnerable)
					{
						//If object is still alive
						if(healthController.health > 0.0f)
						{
							healthController.health = 0.0f;
							healthController.isDead = true;
						}
					}
				}
			}
		}
	}
    // Use this for initialization
    void Awake()
    {
        if(gameObject.name == "Player 1")
        {
            playerNum = 1;
        }
        else if (gameObject.name == "Player 2")
        {
            playerNum = 2;
        }

        if(PlayerPrefs.HasKey("Player " + playerNum + " special"))
        {
            type = PlayerPrefs.GetString("Player " + playerNum + " special");
        }

        Debug.Log (playerNum + " " + type);

        hpControl = GameObject.Find ("HealthBar " + playerNum).GetComponent<HealthController>();
        ManaBar = GameObject.Find ("ManaBar " + playerNum).GetComponent<ManaController>();

        hpControl.SetHP (3);
        //PlayerMovement pm = (PlayerMovement)gameObject.GetComponent("PlayerMovement");
        //pm.speed = setspd+2*spd;

        audio = gameObject.GetComponent<AudioPlayer>();
    }
Exemplo n.º 3
0
	// Use this for initialization
	void Awake () {
		butRect = new Rect((Screen.width - ctrlWidth)/2,0,ctrlWidth, ctrlHeight);
		sceneFader = GameObject.FindGameObjectWithTag("GameController").GetComponent<SceneFader>();
		playerHealth = GameObject.FindGameObjectWithTag("Player").GetComponent<HealthController>();
		timer = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>();
		item = GameObject.FindGameObjectWithTag("GameController").GetComponent<Item>();
	}
Exemplo n.º 4
0
	private HealthController playerHealth;		// Reference to the PlayerControl script.
	
	void Awake ()
	{
		// Setting up references.
		playerHealth = GetComponent<HealthController>();
		healthBar = GameObject.Find("HealthBar").GetComponent<SpriteRenderer>();
		healthScale = healthBar.transform.localScale;
	}
Exemplo n.º 5
0
	// Use this for initialization
	void Start()
    {
        healthController = GameObject.FindGameObjectWithTag("Player").GetComponent<HealthController>();
        uiController = GetComponent<UIController>();
        SceneStart();

        CheckRuntimePlatform();
	}
Exemplo n.º 6
0
	public override bool NeedsPickup(GameObject who)
	{
		_health = who.GetComponent<HealthController>();
		if(_health == null)
			return false;

		return ! _health.IsFull;
	}
Exemplo n.º 7
0
	void Awake()
	{
		screenRect = new Rect(0,0,Screen.width,Screen.height);
		currentColor = Color.black;

		//hecki97
		if (lookForPlayer)
			playerHealth = GameObject.FindGameObjectWithTag("Player").GetComponent<HealthController>();
	}
Exemplo n.º 8
0
 public void Awake()
 {
     _controller = GetComponent<CharacterController2D>();
     _healthController = HealthBar.GetComponent<HealthController>();
     _healthController.ResetHealth();
     _isFacingRight = transform.localScale.x > 0;
     Health = MaxHealth;
     _hasGun = false;
 }
    // Use this for initialization
    void Start()
    {
        hCtrl = GetComponent<HealthController> ();

                regenTimer = Time.time;
                maxWill = hCtrl.getMaxHealth ();
                curMaxWill = hCtrl.getCurrentHealth ();
                curWill = maxWill;

                prevHealth = hCtrl.getCurrentHealth ();
    }
 void Awake()
 {
     playerInstance = Instantiate(player, spawn_point, Quaternion.identity) as GameObject;
     health_controller = playerInstance.GetComponent<HealthController>();
     var hudInstance = Instantiate(hud) as GameObject;
     var cameraInstance = Instantiate(camera, camera.transform.position, camera.transform.rotation) as GameObject;
     BuildGridAndRooms();
     StageBuilder.scale = scale;
     stage = new Stage(loadedGrid, loadedRooms, fluff_builder);
     stage.Create();
 }
    private float ShieldActiveCD = 15f; //Cooldown before shields restart

    #endregion Fields

    #region Methods

    void Start()
    {
        EC = GetComponent<EnemyController>();
        Shield = GetComponentInChildren<ShieldController>();
        HC = GetComponent<HealthController>();
        EBS = GetComponent<LMEnergyBallShot>();

        IC = GameObject.FindGameObjectWithTag("Player").GetComponent<InventoryController>();
        P = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>();
        floor = P.getCurrentFloor() + 1;
    }
Exemplo n.º 12
0
	// Use this for initialization
	void Start () {
        timeleft = updateInterval;  
        
        sceneFader = GameObject.FindGameObjectWithTag("GameController").GetComponent<SceneFader>();
        healthController = GameObject.FindGameObjectWithTag("Player").GetComponent<HealthController>();

        ui_timerText = GameObject.Find("UI_Canvas/UI_TimerText").GetComponent<TimerUI>();
        ui_levelInfo = GameObject.Find("UI_Canvas/UI_LevelInfoText").GetComponent<LevelInfoUI>();
        
        ui_healthPoints = GameObject.Find("UI_Canvas/UI_HealthPoints").GetComponent<HealthPointsUI>();
        ui_debug = GameObject.Find("UI_Canvas/UI_Debug").GetComponent<DebugUI>();
	}
 //Start with bomber deactivated at rest
 void Awake()
 {
     Core = gameObject.GetComponent<Transform>();
     PauseAI();
     HC = GetComponent<HealthController>();
     IC = GameObject.FindGameObjectWithTag("Player").GetComponent<InventoryController>();
     P = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>();
     RB = GetComponent<Rigidbody>();
     floor = P.getCurrentFloor() + 1;
     Constraints = RB.constraints;
     RB.constraints = RigidbodyConstraints.FreezeAll;
 }
Exemplo n.º 14
0
 public override void Start(AI ai)
 {
     base.Start (ai);
             self = ai.WorkingMemory.GetItem<GameObject> ("self");
             aiHealthControl = self.GetComponent<HealthController> ();
             ghostController = GameObject.FindGameObjectWithTag ("GameController").GetComponent<GhostWorldController> ();
             lastHealth = aiHealthControl.getCurrentHealth ();
             gui = self.GetComponent<DebugAP> (); //TODO
             var eCont = self.GetComponent<EquipmentController> ();
             if (eCont != null)
                     selfAtkRng = eCont.GetWeaponRange ();
             //rand = new Random();
 }
Exemplo n.º 15
0
 void OnTriggerStay(Collider other)
 {
     if (other.tag == "Player" && ghostCtrl.deathTransition <= 0) {
                     if (tag != "ActiveCheckpoint") {
                             if (GameObject.FindGameObjectWithTag ("ActiveCheckpoint") != null) {
                                     GameObject.FindGameObjectWithTag ("ActiveCheckpoint").tag = "Untagged";
                             }
                             tag = "ActiveCheckpoint";
                             activateSource.Play ();
                     }
                     hCont = other.GetComponent<HealthController> ();
                     hCont.adjustCurrentHealth (Time.deltaTime * healSpeed);
             }
 }
    // Use this for initialization
    void Awake()
    {
        boss = GameObject.FindGameObjectWithTag("Broodmother");
        health = GetComponent<HealthController>();
        backpack = GetComponent<WeaponBackpackController>();
        anim = GetComponent<Animator>();
        timeSinceSpawn = 0;
        animTimer = 0;
        justSpawned = false;
        PauseAI();

        IC = GameObject.FindGameObjectWithTag("Player").GetComponent<InventoryController>();
        P = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>();
        floor = P.getCurrentFloor() + 1;
    }
Exemplo n.º 17
0
    // Use this for initialization
    void Start()
    {
        selector = GameObject.FindWithTag("Selector");
		
		swordLeftObject = GameObject.FindWithTag("SwordLeft");
		swordRightObject = GameObject.FindWithTag("SwordRight");
		shieldObject = GameObject.FindWithTag("Shield");
		shieldCollider = GameObject.FindWithTag ("ShieldCollider");
		player = GameObject.FindWithTag("Player");
		radar = GameObject.FindWithTag("Radar").GetComponent<ObjectScan>();
        hc = player.GetComponent<HealthController>();
		tempVect = shieldObject.transform.position - transform.position;
        tempVectSwordRight = swordRightObject.transform.position - transform.position;
		//shieldObject.transform.position = randomPosition;
    }
Exemplo n.º 18
0
	//When something collides with the hazard, store the thing that collided with it in the variable "other"
	//For OnTiggerStay to fire, the player has to keep standing in the hazard
	void OnTriggerStay2D (Collider2D collider)
	{
		//Subtract time since last frame from time remaining until applying damage
		damageTimer -= Time.deltaTime;

		//Debug.Log (damageTimer);

		//Initialize HealthController
		healthController = collider.gameObject.GetComponent<HealthController>();

		//If the collider has a healthController
		if (healthController != null)
		{
			//Check if collider = player and onlyHurtPlayer or if it is notHurtPlayer
			if ((collider.gameObject.tag == "Player" && onlyHurtPlayer) || !onlyHurtPlayer) 	
			{
				if (startEnabled)
				{
					//If enough time has passed since damaging the player
					if (damageTimer <= 0.0f) 
					{
						//Reset time since damage last applied
						damageTimer = timeBetweenDamage;

						//Check if the player is invulnerable, otherwise don't hurt him
						if (!healthController.isInvulnerable)
						{
							//If object is still alive
							if(healthController.health > 0.0f)
							{
								//If health is more than damage
								if(healthController.health > damagePerTime)
									//Apply full damage
									healthController.health -= damagePerTime;
								else
									//Set health = 0
									healthController.health = 0.0f;
								
								//Process the hit in coordination with the HealthController
								ProcessHit(collider);
							}
						}
					
					}
				}
			}
		}
	}
Exemplo n.º 19
0
	// Use this for initialization
	void Start () 
	{
		//Find the player and point this variable
		//to them
		player = GameObject.FindWithTag ("Player");

		//Initialize a pointer the the player controller script
		healthController = player.GetComponent<HealthController> ();

		//If there are saved inventory values, use them
		//This data gets saved by EndOfLevel.cs
		if (PlayerPrefs.GetFloat ("Inv1Value") != 0.0f)
			Pickup1InitialValue = PlayerPrefs.GetFloat ("Inv1Value");
		if (PlayerPrefs.GetFloat ("Inv2Value") != 0.0f)
			Pickup2InitialValue = PlayerPrefs.GetFloat ("Inv2Value");
		if (PlayerPrefs.GetFloat ("Inv3Value") != 0.0f)
			Pickup3InitialValue = PlayerPrefs.GetFloat ("Inv3Value");
	}
 // Update is called once per frame
 void Update()
 {
     if (hitScored && (Time.time - hitTime >= displayTime)) {
         hitScored = false;
     }
     if (killScored && (Time.time - killTime >= displayTime)) {
         killScored = false;
     }
     if (redDot == null) {
         redDot = GameObject.FindGameObjectWithTag ("RedDot");
     }
     //if (redDot != null && redDotImage == null) {
     //	redDotImage = redDot.GetComponent<RawImage> ();
     //}
     if (blackDot == null) {
         blackDot = GameObject.FindGameObjectWithTag ("BlackDot");
     }
     //if (blackDot != null && blackDotImage == null) {
     //	blackDotImage = blackDot.GetComponent<RawImage> ();
     //}
     if (redDot != null) {
         redDot.SetActive(killScored);
     }
     if (blackDot != null) {
         if (!killScored && hitScored) {
             blackDot.SetActive(true);
         } else {
             blackDot.SetActive(false);
         }
     }
     if (damaged == null) {
         damaged = GameObject.FindGameObjectWithTag("Damaged");
     }
     if (hcontroller == null) {
         hcontroller = GameObject.FindGameObjectWithTag ("Player").GetComponent<HealthController> ();
     }
     if (damaged != null && hcontroller != null) {
         bool dtaken = (health > hcontroller.GetCurrentHealth());
         health = hcontroller.GetCurrentHealth();
         damaged.SetActive(dtaken);
     }
 }
Exemplo n.º 21
0
    // Use this for initialization
    void Start()
    {
		//Find the player and point this variable
        //to them
        player = GameObject.FindWithTag("Player");

        //Initialize a pointers to controllers and renderer
        healthController = player.GetComponent<HealthController>();
        playerController = player.GetComponent<PlayerController>();

        spriteToHide = this.GetComponent<SpriteRenderer>();

        //Save the original max speed
        originalMaxSpeed = playerController.maxSpeed;

        //Set invulnerable on flag
        invulnerableOn = healthController.isInvulnerable;

		//Get a pointer to the player projectile prefab
		playerProjectilePrefab = player.GetComponent<WeaponController>().projectilePrefab;
    }
Exemplo n.º 22
0
    public bool MetObject(HealthController.FoodType foodObj)
    {
        bool ret = false;
        switch (foodObj)
        {
            case HealthController.FoodType.Hunter:
                if (godModeBonusActivator.getIsActive())
                {
                    healthController.OnEatenFood(foodObj);
                    ret = true;
                }
                else
                {
                    //gameController.playerKilled();
                }
                break;

            case HealthController.FoodType.RedHood:
                godModeCounter++;
                //godModeCounterText.setText(godModeCounter+"/"+godModeParm);
                godModeCounterText.setText(godModeCounter+"/"+godModeParm+"\nuntil God Mode");
                giveBonus(false);
                healthController.OnEatenFood(foodObj);
                ret = true;
                break;

            case HealthController.FoodType.Granny:
                giveBonus(true);
                healthController.OnEatenFood(foodObj);
                ret = true;
                break;

            default:
                healthController.OnEatenFood(foodObj);
                ret = true;
                break;
        }

        return ret;
    }
Exemplo n.º 23
0
    void Update()
    {
        if (!game.isInGhostMode)
        {
            Destroy(gameObject);
        }

        if (spawn && game.isInGhostMode)
        {
            hCtrl = GameObject.FindWithTag("Player").GetComponent<HealthController>();
            if (game.timeLeftToReviveFromGhostMode <= game.timeToReviveInGhostMode)
            {
                GameObject.FindWithTag("Player").GetComponent<MovementController>().SetCanMove(false);
                game.timeLeftToReviveFromGhostMode += reviveSpeed * Time.deltaTime;
            } else
            {
                hCtrl.adjustCurrentHealth(hCtrl.getMaxHealth() - hCtrl.getCurrentHealth());
                GameObject.FindWithTag("Player").GetComponent<MovementController>().SetCanMove(true);
            }
        } else if (game.isInGhostMode)
        {
            spawn = false;
        }
    }
Exemplo n.º 24
0
 // Use this for initialization
 void Start()
 {
     hc = GameObject.Find ("Health").GetComponent<HealthController>();
 }
    private void Start()
    {
        camera = GameObject.FindGameObjectWithTag("MainCamera"); //Find the camera
        CamControl = camera.GetComponent<CameraController>();
        hud = GameObject.FindGameObjectWithTag("HUD");
        player = GameObject.FindGameObjectWithTag("Player");

        GameObject notificationLog = GameObject.FindWithTag("Log");
        Log = notificationLog.GetComponent<LogScript>();

        movement_controller = GetComponent<MovementController>();
        weapon_backpack_controller = GetComponent<WeaponBackpackController>();
        healthController = GetComponent<HealthController>();
        RB = GetComponent<Rigidbody>();

        Flashlight = GetComponentInChildren<FlashlightController>();  //Attach the flashlight
        Particles = GetComponentsInChildren<ParticleSystem>();       //Attach the powerfists
        SetPowerfists(false);

        Drop = false;
        TrackFace = true;
        this.toggle_movement = false;

        ScreenSize = new Vector3(Screen.width, Screen.height);

        doubleTapCountdown = 0;
        //doubleTapCounts = new int[4];
        doubleTapCount = 0;
        //resetDoubleTapCount();
        dashDirection = new Vector2(0, 0);
        //dashCooldownCountdown = 0;
        this.isDashing = false;
        dashForceCurrent = 1;
        dashStartTime = 0;
        isStunned = false;
        stunCountdown = 0;
        SetStunElectricity(false);

        //currentFloor = 0;
        dialogueLevel = 0;
        deepestLevelVisited = 0;
        currLevel = 0;
        level = 0;

        defense = 1f;
    }
Exemplo n.º 26
0
 public override void OnApply(HealthController healthController, int value, int duration)
 {
     healthController.SetBonusAttack(value);
     tempValue = value;
     healthController.AddEndOfTurnBuff(this, duration);
 }
Exemplo n.º 27
0
 protected new void Start()
 {
     base.Start();
     parentHealth = transform.parent.GetComponent <HealthController>();
 }
Exemplo n.º 28
0
 private void Start()
 {
     rb = GameObject.FindGameObjectWithTag("Player").GetComponent <Rigidbody2D>();
     healthController = GameObject.FindGameObjectWithTag("Health Controller").GetComponent <HealthController>();
     cameraShake      = GameObject.FindGameObjectWithTag("Screen Shake").GetComponent <CameraShake>();
 }
Exemplo n.º 29
0
 // Use this for initialization
 void Start()
 {
     hCtrl = GetComponent<HealthController>();
 }
Exemplo n.º 30
0
 void Awake()
 {
     _healthCon = gameObject.GetComponent <HealthController>();
     collider   = gameObject.GetComponent <CapsuleCollider>();
 }
Exemplo n.º 31
0
 void Awake()
 {
     _userInteface     = GetComponent <UserInterface>();
     _healthController = GetComponent <HealthController>();
 }
Exemplo n.º 32
0
 void Start()
 {
     hc = GameObject.Find("Player").GetComponent <HealthController> ();
 }
 // Start is called before the first frame update
 void Start()
 {
     health   = GetComponent <HealthController>();
     activate = GetComponent <TerminalActivation>();
 }
Exemplo n.º 34
0
 void Awake()
 {
     this.playerHealth = gameObject.GetComponent <HealthController>();
 }
 protected void StartBody()
 {
     //Automatically attach the player & various components
     player = GameObject.FindGameObjectWithTag("Player");
     health_controller = GetComponent<HealthController>();
     anim = GetComponent<Animator>();
     AggroState = false;
     RBody = GetComponent<Rigidbody>();
     gun = transform.FindChild("Gun Location");
     combo_controller = GameObject.FindGameObjectWithTag("Combo").GetComponent<ComboController>();
     PC = player.GetComponent<PlayerController>();
     pool = GameObject.Find("ObjectPool").GetComponent<ObjectPooling>();
 }
        private void OnEnable()
        {
            m_Target    = (target as HealthController);
            m_BodyParts = serializedObject.FindProperty("m_BodyParts");

            m_HitSounds       = serializedObject.FindProperty("m_HitSounds");
            m_DamageSounds    = serializedObject.FindProperty("m_DamageSounds");
            m_HitVolume       = serializedObject.FindProperty("m_HitVolume");
            m_BreakLegsSound  = serializedObject.FindProperty("m_BreakLegsSound");
            m_BreakLegsVolume = serializedObject.FindProperty("m_BreakLegsVolume");
            m_HealSound       = serializedObject.FindProperty("m_HealSound");
            m_HealVolume      = serializedObject.FindProperty("m_HealVolume");

            m_CoughSound  = serializedObject.FindProperty("m_CoughSound");
            m_CoughVolume = serializedObject.FindProperty("m_CoughVolume");

            m_ExplosionNoise       = serializedObject.FindProperty("m_ExplosionNoise");
            m_ExplosionNoiseVolume = serializedObject.FindProperty("m_ExplosionNoiseVolume");
            m_DeafnessDuration     = serializedObject.FindProperty("m_DeafnessDuration");
            m_NormalSnapshot       = serializedObject.FindProperty("m_NormalSnapshot");
            m_StunnedSnapshot      = serializedObject.FindProperty("m_StunnedSnapshot");

            m_DeadCharacter = serializedObject.FindProperty("m_DeadCharacter");

            // Reorderable List
            m_BodyPartsList = new ReorderableList(serializedObject, m_BodyParts, false, true, true, true)
            {
                drawHeaderCallback = rect =>
                {
                    EditorGUI.LabelField(rect, "Body Part List", EditorStyles.boldLabel);
                },

                drawElementCallback = (rect, index, isActive, isFocused) =>
                {
                    var element     = m_BodyPartsList.serializedProperty.GetArrayElementAtIndex(index);
                    var displayName = element.objectReferenceValue ? ((DamageHandler)element.objectReferenceValue).BodyPart.ToString() : element.displayName;
                    rect.y += 2;

                    if (element.objectReferenceValue != null)
                    {
                        EditorGUI.LabelField(new Rect(rect.x, rect.y, 96, EditorGUIUtility.singleLineHeight), displayName == "FullBody" ? "Full Body" : displayName);
                    }
                    else
                    {
                        EditorGUI.LabelField(new Rect(rect.x, rect.y, 96, EditorGUIUtility.singleLineHeight), "Body Part");
                    }

                    EditorGUI.PropertyField(new Rect(rect.x + 96, rect.y, rect.width - 96, EditorGUIUtility.singleLineHeight), element, GUIContent.none);
                },

                onSelectCallback = list =>
                {
                    var prefab = list.serializedProperty.GetArrayElementAtIndex(list.index).objectReferenceValue as GameObject;
                    if (prefab != null)
                    {
                        EditorGUIUtility.PingObject(prefab.gameObject);
                    }
                },

                onCanRemoveCallback = list => list.count > 0,
            };

            m_HitSoundsList    = EditorUtilities.CreateReorderableList(m_HitSounds, "Sound");
            m_DamageSoundsList = EditorUtilities.CreateReorderableList(m_DamageSounds, "Sound");
        }
Exemplo n.º 37
0
 void Die(HealthController x)
 {
     Instantiate(deathParticle, transform.position, transform.rotation);
     Destroy(gameObject);
 }
Exemplo n.º 38
0
    // Start is called before the first frame update
    void Start()
    {
        /* Zara Initialization code start =======>> */

        ZaraEngine.Helpers.InitializeRandomizer(UnityEngine.Random.Range);

        _dateTime  = DateTime.Now;
        _timeOfDay = TimesOfDay.Evening;
        _health    = new HealthController(this);
        _body      = new BodyStatusController(this);
        _weather   = new WeatherDescription();
        _player    = new PlayerStatus();
        _inventory = new InventoryController(this);

        _body.Initialize();
        _health.Initialize();

        /* <<======= Zara Initialization code end */

        #region Demo app init

        // Let's add some items to the inventory to play with in this demo

        var flaskWithWater = new ZaraEngine.Inventory.Flask();

        flaskWithWater.FillUp(WorldTime.Value);
        //flaskWithWater.Disinfect(WorldTime.Value);

        _jacket = new ZaraEngine.Inventory.WaterproofJacket();
        _pants  = new ZaraEngine.Inventory.WaterproofPants();
        _boots  = new ZaraEngine.Inventory.RubberBoots();
        _hat    = new ZaraEngine.Inventory.LeafHat();

        _inventory.AddItem(flaskWithWater);

        _inventory.AddItem(_jacket);
        _inventory.AddItem(_pants);
        _inventory.AddItem(_boots);
        _inventory.AddItem(_hat);

        var meat = new ZaraEngine.Inventory.Meat {
            Count = 1
        };

        // We just gathered two of spoiled Meat.
        meat.AddGatheringInfo(WorldTime.Value.AddHours(-5), 2);

        // We just gathered one item of fresh Meat. These will spoil in MinutesUntilSpoiled game minutes.
        meat.AddGatheringInfo(WorldTime.Value, 1);

        _inventory.AddItem(new ZaraEngine.Inventory.Cloth {
            Count = 20
        });
        _inventory.AddItem(meat);
        _inventory.AddItem(new ZaraEngine.Inventory.AntisepticSponge {
            Count = 5
        });
        _inventory.AddItem(new ZaraEngine.Inventory.Bandage {
            Count = 5
        });
        _inventory.AddItem(new ZaraEngine.Inventory.Acetaminophen {
            Count = 10
        });
        _inventory.AddItem(new ZaraEngine.Inventory.Antibiotic {
            Count = 10
        });
        _inventory.AddItem(new ZaraEngine.Inventory.Aspirin {
            Count = 10
        });
        _inventory.AddItem(new ZaraEngine.Inventory.EmptySyringe {
            Count = 10
        });
        _inventory.AddItem(new ZaraEngine.Inventory.Loperamide {
            Count = 10
        });
        _inventory.AddItem(new ZaraEngine.Inventory.Oseltamivir {
            Count = 10
        });
        _inventory.AddItem(new ZaraEngine.Inventory.Sedative {
            Count = 10
        });
        _inventory.AddItem(new ZaraEngine.Inventory.AtropineSolution {
            Count = 10
        });
        _inventory.AddItem(new ZaraEngine.Inventory.EpinephrineSolution {
            Count = 10
        });
        _inventory.AddItem(new ZaraEngine.Inventory.AntiVenomSolution {
            Count = 10
        });
        _inventory.AddItem(new ZaraEngine.Inventory.DoripenemSolution {
            Count = 10
        });
        _inventory.AddItem(new ZaraEngine.Inventory.MorphineSolution {
            Count = 10
        });
        _inventory.AddItem(new ZaraEngine.Inventory.DisinfectingPellets {
            Count = 5
        });

        RefreshConsumablesUICombo();
        RefreshToolsUICombo();

        // Defaults
        _weather.SetTemperature(27f);
        _weather.SetWindSpeed(2f);
        _weather.SetRainIntensity(0f);

        #endregion
    }
Exemplo n.º 39
0
    public override void Process(GameObject caster, CardEffectsController effectController, GameObject target, Card card, int effectIndex)
    {
        HealthController targetHealth = target.GetComponent <HealthController>();

        effectController.GetCard().SetTempEffectValue(targetHealth.GetCurrentVit() - targetHealth.GetMaxVit());
    }
Exemplo n.º 40
0
 public HealthControllerTests()
 {
     _healthController = new HealthController();
 }
Exemplo n.º 41
0
 // Start is called before the first frame update
 void Start()
 {
     HealthController    = GetComponent <HealthController>();
     CharacterController = GetComponent <CharacterController>();
 }
Exemplo n.º 42
0
 void Awake()
 {
     health_controller = GetComponent <HealthController>();
     weapon_controller = GetComponent <WeaponController>();
 }
Exemplo n.º 43
0
 public override void Trigger(HealthController healthController)
 {
 }
Exemplo n.º 44
0
 public HealthShould()
 {
     controller = new HealthController();
 }
Exemplo n.º 45
0
 public override void Revert(HealthController healthController)
 {
     healthController.SetBonusAttack(-tempValue);
 }
Exemplo n.º 46
0
    public override void HandleEvent(GEvent e)
    {
        HealthController Unit = (HealthController)GuidList.GetGameObject((string)e.Arguments [0]).GetComponent("HealthController");

        Unit.DamageUnit((float)e.Arguments[1], GetTeam((string)e.Arguments [0]));
    }
Exemplo n.º 47
0
        //Process the network messages sent by the server. We stored them in a queue during OnReceived(). TODO incomplete
        private void ProcessServerMessages()
        {
            //Only process this function if there is data in queue
            if (dataQueue.Count <= 0)
            {
                return;
            }

            if (JsonUtility.FromJson <FlagNetMsg>(dataQueue.Peek()).flag == Flag.CONNECT)
            {
                isConnected     = true;
                showIfConnected = isConnected;

                if (bDebug)
                {
                    Debug.Log("[Notice] Client connection established with " + udp.Client.RemoteEndPoint.ToString() + ".");
                }
                if (consoleRef)
                {
                    consoleRef.UpdateChat("[Console] Client connection established with server.");
                }
                Debug.Log("[TEMP TEST] Active Scene is '" + SceneManager.GetActiveScene().name + "'.");
                dataQueue.Dequeue();
            }
            else if (!isConnected)
            {
                Debug.LogError("[Error] Received message from server, but cannot process it because client is not connected to server.");
                dataQueue.Clear();
                return;
            }
            else if (JsonUtility.FromJson <FlagNetMsg>(dataQueue.Peek()).flag == Flag.CREATE_ACCOUNT)
            {
                if (bDebug)
                {
                    Debug.Log("[Notice] New account created.");
                }

                if (consoleRef)
                {
                    consoleRef.UpdateChat("[Console] Account created successfully.");
                }
                Debug.Log("[TEMP TEST] Active Scene is '" + SceneManager.GetActiveScene().name + "'.");

                if (loginCtrlRef)
                {
                    loginCtrlRef.AccountCreated();
                }
                else if (GameObject.Find("Canvas/Login Controller"))
                {
                    loginCtrlRef = GameObject.Find("Canvas/Login Controller").GetComponent <LoginController>();
                    loginCtrlRef.AccountCreated();
                }

                dataQueue.Dequeue();
            }
            else if (JsonUtility.FromJson <FlagNetMsg>(dataQueue.Peek()).flag == Flag.FAILED_ACCOUNT_CREATION)
            {
                if (bDebug)
                {
                    Debug.Log("[Notice] Failed to create new account.");
                }

                if (consoleRef)
                {
                    consoleRef.UpdateChat("[Console] Failed to create account; Invalid username or password.");
                }

                if (loginCtrlRef)
                {
                    loginCtrlRef.UserExists();
                }
                else if (GameObject.Find("Canvas/Login Controller"))
                {
                    loginCtrlRef = GameObject.Find("Canvas/Login Controller").GetComponent <LoginController>();
                    loginCtrlRef.UserExists();
                }

                dataQueue.Dequeue();
            }
            else if (JsonUtility.FromJson <FlagNetMsg>(dataQueue.Peek()).flag == Flag.LOGIN_ACCOUNT)
            {
                isLoggedIn = true;
                GameStateManager.SetState(State.GAMESELECTSCENE);
                if (bDebug)
                {
                    Debug.Log("[Notice] Client has successfully logged in.");
                }

                //TODO: Exit login screen; Load next scene

                if (consoleRef)
                {
                    consoleRef.UpdateChat("[Console] Successfully logged in.");
                }
                Debug.Log("[TEMP TEST] Active Scene is '" + SceneManager.GetActiveScene().name + "'.");

                if (loginCtrlRef)
                {
                    loginCtrlRef.ConfirmServerLogin();
                }
                else if (GameObject.Find("Canvas/Login Controller"))
                {
                    loginCtrlRef = GameObject.Find("Canvas/Login Controller").GetComponent <LoginController>();
                    loginCtrlRef.ConfirmServerLogin();
                }

                dataQueue.Dequeue();
            }
            else if (JsonUtility.FromJson <FlagNetMsg>(dataQueue.Peek()).flag == Flag.FAILED_LOGIN)
            {
                if (bDebug)
                {
                    Debug.Log("[Notice] Failed to log in.");
                }

                if (consoleRef)
                {
                    consoleRef.UpdateChat("[Console] Login failed; Invalid username or password.");
                }

                if (loginCtrlRef)
                {
                    loginCtrlRef.IncorrectLogin();
                }
                else if (GameObject.Find("Canvas/Login Controller"))
                {
                    loginCtrlRef = GameObject.Find("Canvas/Login Controller").GetComponent <LoginController>();
                    loginCtrlRef.IncorrectLogin();
                }

                dataQueue.Dequeue();
            }
            else if (JsonUtility.FromJson <FlagNetMsg>(dataQueue.Peek()).flag == Flag.PING)  //Received a ping from the server
            {
                if (bDebug && bVerboseDebug)
                {
                    Debug.Log("[Routine] Received flag from server: PING.");
                }
                ResponsePong(); //Send a response pong message
                dataQueue.Dequeue();
            }
            else if (JsonUtility.FromJson <FlagNetMsg>(dataQueue.Peek()).flag == Flag.VERSION)  //Receives a version request from server. Note: Not used in this case as the client sends the version with the first CONNECT message
            {
                if (bDebug)
                {
                    Debug.Log("[Routine] Received flag from server: VERSION.");
                }
                ResponseVersion();
                dataQueue.Dequeue();
            }
            else if (JsonUtility.FromJson <FlagNetMsg>(dataQueue.Peek()).flag == Flag.INVALID_VERSION)  //Receives an invalid version message from server
            {
                if (bDebug)
                {
                    Debug.Log("[Notice] Received flag from server: INVALID_VERSION.");
                }

                if (consoleRef)
                {
                    consoleRef.UpdateChat("[Console] Incompatible client version; disconnecting from server...");
                }

                Disconnect();
                dataQueue.Dequeue();
            }
            else if (!isLoggedIn)
            {
                Debug.LogError("[Error] Received message from server, but cannot process it because client is not logged in.");
                dataQueue.Dequeue();
                return;
            }
            else if (JsonUtility.FromJson <FlagNetMsg>(dataQueue.Peek()).flag == Flag.QUEUE_MATCHMAKING)
            {
                isInMMQueue = true;
                if (bDebug)
                {
                    Debug.Log("[Notice] Received flag from server: QUEUE_MATCHMAKING.");
                }

                if (consoleRef)
                {
                    consoleRef.UpdateChat("[Console] You have joined matchmaking queue.");
                }
                Debug.Log("[TEMP TEST] Active Scene is '" + SceneManager.GetActiveScene().name + "'.");
                dataQueue.Dequeue();
            }
            else if (JsonUtility.FromJson <FlagNetMsg>(dataQueue.Peek()).flag == Flag.FAILED_MMQUEUE)
            {
                if (bDebug)
                {
                    Debug.Log("[Notice] Received flag from server: FAILED_MMQUEUE.");
                }

                if (consoleRef)
                {
                    consoleRef.UpdateChat("[Console] You have failed to join matchmaking queue.");
                }
                dataQueue.Dequeue();
            }
            else if (JsonUtility.FromJson <FlagNetMsg>(dataQueue.Peek()).flag == Flag.MATCH_START)
            {
                MoveUpdateData playersData = JsonUtility.FromJson <MoveUpdateData>(dataQueue.Peek());
                isInMatch = true;

                //Receive lobby data
                foreach (PlayerMoveData player in playersData.players)
                {
                    //Update player position and orientation data, and health
                    //Adds players to clientDataDict that aren't added yet
                    UpdatePlayer(player.username, player.position.x, player.position.y, player.position.z, player.orientation.yaw, player.orientation.pitch, player.health);
                }

                if (bDebug)
                {
                    Debug.Log("[Notice] Client's game match has started.");
                }

                if (consoleRef)
                {
                    consoleRef.UpdateChat("[Console] The match is starting...");
                }
                Debug.Log("[TEMP TEST] Active Scene is '" + SceneManager.GetActiveScene().name + "'.");

                if (!selectCtrlRef)
                {
                    if (GameObject.Find("SelectionController"))
                    {
                        selectCtrlRef = GameObject.Find("SelectionController").GetComponent <SelectionController>();
                        selectCtrlRef.MatchmakingComplete();
                    }
                }
                else
                {
                    selectCtrlRef.MatchmakingComplete();
                }

                dataQueue.Dequeue();
            }
            else if (JsonUtility.FromJson <FlagNetMsg>(dataQueue.Peek()).flag == Flag.LEAVE_MATCHMAKING)
            {
                isInMMQueue = false;
                isInMatch   = false;

                if (bDebug)
                {
                    Debug.Log("[Notice] Client has left matchmaking queue.");
                }

                if (consoleRef)
                {
                    consoleRef.UpdateChat("[Console] You have left matchmaking queue.");
                }
                dataQueue.Dequeue();
            }
            else if (JsonUtility.FromJson <FlagNetMsg>(dataQueue.Peek()).flag == Flag.FETCH_ACCOUNT)
            {
                if (bDebug)
                {
                    Debug.Log("[Notice] Retrieved profile data.");
                }

                if (consoleRef)
                {
                    consoleRef.UpdateChat("[Console] Retrieved profile data.");
                }
                Debug.Log("[TEMP TEST] Active Scene is '" + SceneManager.GetActiveScene().name + "'.");

                if (!profileMgrRef)
                {
                    if (GameObject.Find("ProfileManager"))
                    {
                        profileMgrRef = GameObject.Find("ProfileManager").GetComponent <ProfileMgr>();
                        profileMgrRef.SetProfile(clientUsername, 1500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); //TODO TEMP
                        clientUsername = profileMgrRef._Username;
                    }
                }
                else
                {
                    profileMgrRef.SetProfile(clientUsername, 1500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); //TODO TEMP
                    clientUsername = profileMgrRef._Username;
                }

                dataQueue.Dequeue();
            }
            else if (JsonUtility.FromJson <FlagNetMsg>(dataQueue.Peek()).flag == Flag.FAILED_FETCH)
            {
                if (bDebug)
                {
                    Debug.Log("[Notice] Failed to retrieve profile data.");
                }

                if (consoleRef)
                {
                    consoleRef.UpdateChat("[Console] Failed to retrieve profile data.");
                }
                dataQueue.Dequeue();
            }
            else if (JsonUtility.FromJson <FlagNetMsg>(dataQueue.Peek()).flag == Flag.MATCH_UPDATE)
            {
                MoveUpdateData playersData = JsonUtility.FromJson <MoveUpdateData>(dataQueue.Peek());
                if (bDebug && bVerboseDebug)
                {
                    Debug.Log("[Notice] Received Match Update.");
                }

                if (bDebug && bVerboseDebug)
                {
                    Debug.Log("[TEMP TEST] Active Scene is '" + SceneManager.GetActiveScene().name + "'.");
                }

                //Receive lobby data
                foreach (PlayerMoveData player in playersData.players)
                {
                    //Update player position and orientation data, and health
                    //Adds players to clientDataDict that aren't added yet
                    UpdatePlayer(player.username, player.position.x, player.position.y, player.position.z, player.orientation.yaw, player.orientation.pitch, player.health);
                }

                dataQueue.Dequeue();
            }
            else if (JsonUtility.FromJson <FlagNetMsg>(dataQueue.Peek()).flag == Flag.MISSSHOT_UPDATE)
            {
                MissShotsData shotData = JsonUtility.FromJson <MissShotsData>(dataQueue.Peek());
                Debug.Log("[Temp Debug] dataQueue.Count: " + dataQueue.Count);
                dataQueue.Dequeue();

                Debug.Log("[Notice] Received Missed Shot Update.");
                if (bDebug && bVerboseDebug)
                {
                    Debug.Log("[TEMP TEST] Active Scene is '" + SceneManager.GetActiveScene().name + "'.");
                }

                //Dont process gunshots from own client
                if (shotData.usernameOrigin == clientUsername)
                {
                    Debug.Log("    [Notice] Will not process own gunshots...");
                    return;
                }

                if (!gameMgrRef)
                {
                    if (GameObject.Find("GameManager"))
                    {
                        gameMgrRef = GameObject.Find("GameManager").GetComponent <GameplayManager>();
                    }
                }

                if (gameMgrRef)
                {
                    if (clientDataDict.ContainsKey(shotData.usernameOrigin))
                    {
                        StartCoroutine(gameMgrRef.ConveyMissShot(clientDataDict[shotData.usernameOrigin].objChaserReference, new Vector3(shotData.hitPosition.x, shotData.hitPosition.y, shotData.hitPosition.z)));
                    }
                    else
                    {
                        Debug.LogError("[Error] shotData.usernameOrigin is not a valid key in clientDataDict; cannot update miss shot.");
                    }
                }
                else
                {
                    Debug.LogError("[Error] GameplayManager reference missing; cannot update miss shot.");
                }
            }
            else if (JsonUtility.FromJson <FlagNetMsg>(dataQueue.Peek()).flag == Flag.HITSCAN_UPDATE)
            {
                HitScanData shotData = JsonUtility.FromJson <HitScanData>(dataQueue.Peek());

                Debug.Log("[Notice] Received Hit Scan Update.");
                if (bDebug && bVerboseDebug)
                {
                    Debug.Log("[TEMP TEST] Active Scene is '" + SceneManager.GetActiveScene().name + "'.");
                }

                //Dont process gunshots from own client
                if (shotData.usernameOrigin == clientUsername)
                {
                    return;
                }

                if (!gameMgrRef)
                {
                    if (GameObject.Find("GameManager"))
                    {
                        gameMgrRef = GameObject.Find("GameManager").GetComponent <GameplayManager>();
                    }
                }

                if (gameMgrRef)
                {
                    if (clientDataDict.ContainsKey(shotData.usernameOrigin) && clientDataDict.ContainsKey(shotData.usernameTarget))
                    {
                        if (shotData.damage == 0)   //TODO BANDAID FIX
                        {
                            shotData.damage = 20;
                        }

                        //subtract from health
                        if (clientDataDict[shotData.usernameTarget].health - shotData.damage <= 0)
                        {
                            clientDataDict[shotData.usernameTarget].health = 0;
                            StartCoroutine(BandaidDeathRoutine());
                            //SendDeathMessage(shotData.usernameOrigin, shotData.usernameTarget);
                        }
                        else if (clientDataDict[shotData.usernameTarget].health - shotData.damage > 100)
                        {
                            clientDataDict[shotData.usernameTarget].health = 100;
                        }
                        else
                        {
                            clientDataDict[shotData.usernameTarget].health = clientDataDict[shotData.usernameTarget].health - shotData.damage;
                        }

                        Debug.Log("[Notice] health: " + clientDataDict[shotData.usernameTarget].health);

                        if (shotData.usernameTarget == clientUsername)
                        {
                            //update health bar
                            if (!hpBarCtrlRef)
                            {
                                hpBarCtrlRef = GameObject.Find("Canvas/Health").GetComponent <HealthController>();
                            }
                            if (hpBarCtrlRef)
                            {
                                hpBarCtrlRef.HitMe();
                            }
                            StartCoroutine(gameMgrRef.ConveyHitShot(clientDataDict[shotData.usernameOrigin].objChaserReference, clientDataDict[shotData.usernameTarget].objReference, new Vector3(shotData.hitPosition.x, shotData.hitPosition.y, shotData.hitPosition.z), shotData.damage));
                        }
                        else
                        {
                            StartCoroutine(gameMgrRef.ConveyHitShot(clientDataDict[shotData.usernameOrigin].objChaserReference, clientDataDict[shotData.usernameTarget].objChaserReference, new Vector3(shotData.hitPosition.x, shotData.hitPosition.y, shotData.hitPosition.z), shotData.damage));
                        }
                        Debug.Log("[Notice] " + shotData.usernameTarget + " received " + shotData.damage + " gunfire damage from " + shotData.usernameOrigin);
                    }
                    else
                    {
                        Debug.LogError("[Error] shotData.usernameOrigin is not a valid key in clientDataDict; cannot update hit shot.");
                    }
                }
                else
                {
                    Debug.LogError("[Error] GameplayManager reference missing; cannot update hit shot.");
                }
                dataQueue.Dequeue();
            }
            else if (JsonUtility.FromJson <FlagNetMsg>(dataQueue.Peek()).flag == Flag.RESPAWN)
            {
                RespawnMessage spawnData = JsonUtility.FromJson <RespawnMessage>(dataQueue.Peek());

                Debug.Log("[Notice] Received respawn message.");

                Respawn(new Vector3(spawnData.spawn.x, spawnData.spawn.y, spawnData.spawn.z));
                dataQueue.Dequeue();
            }
            else if (JsonUtility.FromJson <FlagNetMsg>(dataQueue.Peek()).flag == Flag.MATCH_END)
            {
                dataQueue.Dequeue();
            }
        }
Exemplo n.º 48
0
 // Use this for initialization
 void Awake()
 {
     Instance    = this;
     healthLogic = new HealthLogic();
 }
Exemplo n.º 49
0
 void Start()
 {
     PlayerHealthController = Player.GetComponent <HealthController>();
 }
Exemplo n.º 50
0
 // Start is called before the first frame update
 void Start()
 {
     HealthController        = GetComponent <HealthController>();
     HealthController.OnDie += Die;
 }
	public void Start()
	{
		GameObject player = FindObjectOfType<SidescrollingPlayerControl>().gameObject;
		_health = player.GetComponent<HealthController>();
		_mana = player.GetComponent<ManaController>();
	}
Exemplo n.º 52
0
 void Die(HealthController x)
 {
     Instantiate(SmokeInstance, transform.position, Quaternion.identity);
     Destroy(gameObject);
 }
Exemplo n.º 53
0
	// Use this for initialization
	void Start () {
		characterController = GetComponent<CharacterController>();
		//spriteController = GetComponent<SpriteController>();
		healthController = GetComponent<HealthController>();
	}
Exemplo n.º 54
0
 virtual protected void Awake()
 {
     _healthController = GetComponent <HealthController>();
 }
Exemplo n.º 55
0
 protected override void Start()
 {
     base.Start();
     health = GetComponent <HealthController>();
 }
Exemplo n.º 56
0
 // Start is called before the first frame update
 void Start()
 {
     healthController = GetComponent <HealthController>();
 }
Exemplo n.º 57
0
 void Awake()
 {
     healthController = GetComponent <HealthController>();
 }
Exemplo n.º 58
0
 private void Awake()
 {
     _healthController = GetComponent <HealthController>();
 }
Exemplo n.º 59
0
 void Awake()
 {
     healthController = GetComponent<HealthController>();
 }
Exemplo n.º 60
0
 public FatigueHealthEffectsController(IGameController gc, HealthController health)
 {
     _gc = gc;
     _healthController = health;
 }