Пример #1
0
    protected new void Start()
    {
        base.Start();

        status = StatusType.Live;

        if (showHealthBar)
        {
            var hb = Instantiate(Resources.Load(configs.prefabPaths.uiHealthbar), new Vector3(transform.position.x, transform.position.y - transform.lossyScale.y), Quaternion.identity) as GameObject;
            hb.transform.parent = transform;
            healthBar           = hb.GetComponent <HealthBarController>();
            healthBar.setHealth(health);
            healthBar.divider = health;
            healthBar.yMargin = healthBarYMargin;
        }

        OnHit += (o) => {
            if (o.hits != null && System.Array.IndexOf(o.hits, this.GetType()) > -1)
            {
                decHealth(o.damage);
                spriteRenderer.color = Color.red;
                CancelInvoke("switchBackToOriginalColor");
                Invoke("switchBackToOriginalColor", .2f);
            }
        };

        build();
    }
Пример #2
0
 public void UpdateHealth(int health)
 {
     HP.SetActive(true);
     HealthBar = FindObjectOfType(typeof(HealthBarController)) as HealthBarController;
     if (health == 5)
     {
         HealthBar.actualSprite = HPEgalSix;
     }
     else if (health == 4)
     {
         HealthBar.actualSprite = HPEgalCinq;
     }
     else if (health == 3)
     {
         HealthBar.actualSprite = HPEgalQuatre;
     }
     else if (health == 2)
     {
         HealthBar.actualSprite = HPEgalTrois;
     }
     else if (health == 1)
     {
         HealthBar.actualSprite = HPEgalDeux;
     }
     else if (health == 0)
     {
         HealthBar.actualSprite = HPEgalUn;
     }
 }
Пример #3
0
 void Awake()
 {
     audioCont     = FindObjectOfType <AudioController>();
     abilityCont   = FindObjectOfType <AbilityController>();
     challengeCont = FindObjectOfType <ChallengeController>();
     spawnCont     = FindObjectOfType <SpawnController>();
     UICont        = FindObjectOfType <UIController>();
     isFollowing   = true;
     fireParticles = GetComponentsInChildren <ParticleSystem>();
     healthBarCont = FindObjectOfType <HealthBarController>();
     float[] zeroDataFloat = new float[11];
     for (int i = 0; i < zeroDataFloat.Length; i++)
     {
         zeroDataFloat[i] = 0;
     }
     damageTaken        = zeroDataFloat;
     gameCont           = FindObjectOfType <GameController>();
     life               = defaultLife;
     camera             = FindObjectOfType <CameraController>();
     transform.position = new Vector3(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y, 0);
     rig           = GetComponent <Rigidbody2D>();
     position      = transform.position;
     isMobileBuild = (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer) ? true : false;
     StartCoroutine(RestartPosition());
     effect = Instantiate(abilityEffects[abilityCont.GetActiveAbility()], transform);
     effect.transform.localPosition = Vector3.zero;
     //audioSource = effect.GetComponentInChildren<AudioSource>();
     comboCount = 0;
     comboSum   = 0;
 }
 private void HealthChanged(float health)
 {
     if (HealthBarController != null)
     {
         HealthBarController.UpdateLine(CurrentHealth, MaxHealth);
     }
 }
Пример #5
0
    void Start()
    {
        health = 100;
        score  = 0;
        updateScore();
        gameOver = false;



        GameObject gameControlObject = GameObject.FindWithTag("ui");

        if (gameControlObject != null)
        {
            gameOverScript = gameControlObject.GetComponent <GameOverScript>();
            healthInstance = healthBarController.GetComponent <HealthBarController>();
            healthInstance.setMaxHealth(100.0f);
            healthInstance.setHealth(100.0f);
        }
        if (gameControlObject == null)
        {
            Debug.Log("Sorry ,Couldn't find object");
        }
        StartCoroutine(SpawnWaves());
        StartCoroutine(spawnPowerUps());
    }
Пример #6
0
	void Start ()
	{
		stageEnd_left = -30.0f;
		stageEnd_right = 30.0f;
		wait_for_start = true;
		firstTime = true;
		paused = false;
		GameObject mainCameraObj = GameObject.Find ("Camera");
		GameObject healthBars = GameObject.Find ("HealthBars");
		GameObject player1Obj = GameObject.Find ("Player1");
		GameObject player2Obj = GameObject.Find ("Player2");
		GameObject debugTextObj = GameObject.Find ("DebugText");
		GameObject winTextObj = GameObject.Find ("WinText");
		GameObject MIObj = GameObject.Find ("Info");

		MI_gd = MIObj.GetComponent<MenuInfo> ();
		mainCamera = mainCameraObj.GetComponent<CameraController> ();
		healthbarcontroller = healthBars.GetComponent<HealthBarController> ();
		player1 = player1Obj.GetComponent<PlayerController> ();
		player2 = player2Obj.GetComponent<PlayerController> ();
		debugText = debugTextObj.GetComponent<DebugTextController> ();
		winText = winTextObj.GetComponent<Text> ();
		Quit = KeyCode.Escape;
		start_game = KeyCode.G;
		TogglePause = KeyCode.BackQuote;
		ToggleDebugText = KeyCode.Quote;
		winText.text = "";
		winText.color = Color.white;


	}
Пример #7
0
    void Start()
    {
        //おまじない一覧
        rb2d = GetComponent<Rigidbody2D>();//重力
		mannekenPisAnimator = GetComponent<Animator> ();//小僧のアニメーター
        HBC = GameObject.FindWithTag("HealthBar").GetComponent<HealthBarController>();//体力バー関係
    }
Пример #8
0
    // Start is called before the first frame update
    void Start()
    {
        health = 100;
        power  = 100;
        //gameOver = false;



        GameObject gameControlObject = GameObject.FindWithTag("UI");

        if (gameControlObject != null)
        {
            //gameOverScript = gameControlObject.GetComponent<GameOverScript>();
            healthInstance = healthBarController.GetComponent <HealthBarController>();
            powerInstance  = powerBarController.GetComponent <PowerBarController>();

            healthInstance.setMaxHealth(100.0f);
            healthInstance.setHealth(100.0f);

            powerInstance.setMaxPower(100.0f);
            powerInstance.setPower(100.0f);
        }
        if (gameControlObject == null)
        {
            Debug.Log("Sorry ,Couldn't find object");
        }
    }
Пример #9
0
        private void Awake()
        {
            // Remember the original position of the players so match can be reset
            originalPosition = gameObject.transform.position;
            originalRotation = gameObject.transform.rotation;

            ScoreKeeper.resetPlayersEvent          += ResetPlayer;
            SkillSelectionManager.passPlayerSkills += PassPlayerSkill;

            if (MultiplayerMode)
            {
                photonView = GetComponent <PhotonView>();
                if (PhotonNetwork.IsMasterClient)
                {
                    // setting for dummy player on Master client side
                    playerNo             = 2;
                    healthBarController  = GameObject.Find("Player 2 Health").GetComponent <HealthBarController>();
                    cooldownUiController = GameObject.Find("Player 2 Cooldown").GetComponent <CooldownUIController>();
                    // otherPlayer = GameObject.Find("Player 2").GetComponent<PlayerController>();
                }
                else
                {
                    playerNo             = 1;
                    healthBarController  = GameObject.Find("Player 1 Health").GetComponent <HealthBarController>();
                    cooldownUiController = GameObject.Find("Player 1 Cooldown").GetComponent <CooldownUIController>();
                    // otherPlayer = GameObject.Find("Player 1").GetComponent<PlayerController>();
                }
            }
            else
            {
                totalPlayers++;
                playerNo = totalPlayers;
            }
            onSuccessfulBlock += SuccessfulBlock;
        }
Пример #10
0
    void Start()
    {
        stageEnd_left  = -30.0f;
        stageEnd_right = 30.0f;
        wait_for_start = true;
        firstTime      = true;
        paused         = false;
        GameObject mainCameraObj = GameObject.Find("Camera");
        GameObject healthBars    = GameObject.Find("HealthBars");
        GameObject player1Obj    = GameObject.Find("Player1");
        GameObject player2Obj    = GameObject.Find("Player2");
        GameObject debugTextObj  = GameObject.Find("DebugText");
        GameObject winTextObj    = GameObject.Find("WinText");
        GameObject MIObj         = GameObject.Find("Info");

        MI_gd               = MIObj.GetComponent <MenuInfo> ();
        mainCamera          = mainCameraObj.GetComponent <CameraController> ();
        healthbarcontroller = healthBars.GetComponent <HealthBarController> ();
        player1             = player1Obj.GetComponent <PlayerController> ();
        player2             = player2Obj.GetComponent <PlayerController> ();
        debugText           = debugTextObj.GetComponent <DebugTextController> ();
        winText             = winTextObj.GetComponent <Text> ();
        Quit            = KeyCode.Escape;
        start_game      = KeyCode.G;
        TogglePause     = KeyCode.BackQuote;
        ToggleDebugText = KeyCode.Quote;
        winText.text    = "";
        winText.color   = Color.white;
    }
Пример #11
0
 void Start()
 {
     maxHealth       = health;
     healthBar       = gameObject.GetComponentInChildren <HealthBarController> ();
     gameplayManager = FindObjectOfType <GameplayManager> ();
     ApplyDifficultyMultiplier();
 }
 private void Awake()
 {
     if (healthBarControllerInstance == null)
     {
         healthBarControllerInstance = this;
     }
 }
Пример #13
0
 void Update()
 {
     if (_healthBar == null && Vector3.Distance(_player.position, transform.position) < 5f)
     {
         _healthBar = Instantiate(healthBarPrefab, _canvas).GetComponent <HealthBarController>();
     }
 }
Пример #14
0
    // Use this for initialization
    void Start()
    {
        if (health == 0)
        {
            health = MAXHEALTH;
        }
        if (MAXHEALTH == 0)
        {
            MAXHEALTH = BASEHEALTH;
        }


        if (GetComponentInParent <MovementControlScript>() != null)
        {
            if (GetComponentInParent <MovementControlScript>().isPlayerShip)
            {
                healthBar    = GameObject.Find("PlayerHealth").GetComponent <HealthBarController>();
                healthSlider = healthBar.GetComponent <Slider>();
            }
        }

        if (GetComponentInParent <TargetObjective>() != null)
        {
            healthBar    = GameObject.Find("BaseHealth").GetComponent <HealthBarController>();
            healthSlider = healthBar.GetComponent <Slider>();
        }

        if (healthSlider != null)
        {
            healthSlider.value = (float)health;
            Debug.Log("Starting Health: " + health);
        }
    }
Пример #15
0
 void Start()
 {
     instance  = weapon.GetComponent <aiWeaponController> ();
     healthBar = HealthBar.GetComponent <HealthBarController>();
     state     = 0;
     rotSide   = false;
 }
Пример #16
0
    void Awake()
    {
        healthBarController = MonoBehaviour.FindObjectOfType(typeof(HealthBarController)) as HealthBarController;
        fuelBarController   = MonoBehaviour.FindObjectOfType(typeof(FuelBarController)) as FuelBarController;

        if (debugPlayerController != null)
        {
            if (debugPlayerController is IPlayerControllerWithBars)
            {
                player = debugPlayerController as IPlayerControllerWithBars;
                player.HealthChanged += HealthChanged;
                player.FuelChanged   += FuelChanged;
            }
            else
            {
                Debug.Log("Debug Player Controller needs to conform to IPlayerWithBars");
            }
            return;
        }
        PlayerController controller = GetComponent <PlayerController>();

        if (controller is IPlayerControllerWithBars)
        {
            player                = (IPlayerControllerWithBars)controller;
            player.FuelChanged   += FuelChanged;
            player.HealthChanged += FuelChanged;
        }
        else
        {
            Debug.LogError("Player Controller class needs to implement IPlayerWithBars" +
                           "interface to communicate with health and fuel bars");
        }
    }
Пример #17
0
    void generateHealthBar()
    {
        GameObject healthBar = Instantiate(healthBarPrefab) as GameObject;

        healthBarControls = healthBar.GetComponent <HealthBarController>();
        healthBarControls.SetHealthBarData(this.transform, healthPanelRect);
        healthBarControls.transform.SetParent(healthPanelRect, false);
    }
    void Start()
    {
        rb = GetComponent <Rigidbody>();
        healthBarController = healthBarGO.GetComponent <HealthBarController>();
        score = scoreGO.GetComponent <ScoreBarController>();

        //playerModel = new PlayerModel(100);
    }
Пример #19
0
 private void OnEnable()
 {
     _rb = GetComponent <Rigidbody>();
     _initialPosition = _rb.position;
     _playerModel     = new PlayerModel();
     _healthBar.SetActive(true);
     _healthBarController = _healthBar.GetComponent <HealthBarController>();
 }
Пример #20
0
    void Start()
    {
        controller  = GetComponent <CharacterController>();
        HealthBar   = FindObjectOfType <HealthBarController>();
        GameManager = FindObjectOfType <GameManager>();

        CheckIfControllerConnected();
    }
Пример #21
0
 // Start is called before the first frame update
 void Start()
 {
     settings   = GameObject.Find("GameMaster").GetComponent <GameSettings>();
     bodyObject = transform.parent.gameObject;
     random     = new System.Random();
     player     = GameObject.FindWithTag("Player");
     healthBar  = GameObject.Find("HealthBar").GetComponent <HealthBarController>();
 }
Пример #22
0
 // Start is called before the first frame update
 void Start()
 {
     playerBody   = GameObject.FindGameObjectWithTag("Player").transform;
     rb           = GetComponent <Rigidbody>();
     playerDamage = GameObject.Find("Player").GetComponent <PlayerController>();
     healthBar    = GameObject.Find("Health_Bar").GetComponent <HealthBarController>();
     transform.LookAt(playerBody);
 }
Пример #23
0
    private void InitHealth()
    {
        healthBarController = healthBar.GetComponent <HealthBarController>();
        healthBarController.SetMaxHealth(maxHealth);
        healthBarController.SetHealth(maxHealth);

        currentHealth = maxHealth;
    }
 void Start()
 {
     _healthBarController   = GameObject.Find("HP Bar").GetComponent <HealthBarController>();
     _currentActorAnimator  = GetComponent <Animator>();
     _isAliveComponent      = GetComponent <IsAliveComponent>();
     _currentTransform      = GetComponent <Transform>();
     _playerStatsController = GetComponent <ActorStatsController>();
 }
 void Update()
 {
     if (_healthBar == null && Vector3.Distance(_player.position, transform.position) < 5f)
     {
         GameObject healthBarObject = Instantiate(healthBarPrefab, _canvas);
         _healthBar = healthBarObject.GetComponent <HealthBarController>();
         healthBarObject.transform.Find("BossName").GetComponent <TextMeshProUGUI>().text = "Gluttony";
     }
 }
    void Awake()
    {
        if (Instance != null)
        {
            Debug.LogError("Multiple instances of HealthBarController!");
        }

        Instance = this;
    }
Пример #27
0
 void Awake()
 {
     if (Instance != null)
     {
         Debug.LogError("Multiple instances of HealthBarController!");
     }
     icon     = GameObject.Find("ProgressIcon");
     Instance = this;
 }
Пример #28
0
    void Start()
    {
        maxHealth       = health;
        healthBar       = gameObject.GetComponentInChildren <HealthBarController> ();
        gameplayManager = FindObjectOfType <GameplayManager> ();

        audioManager = FindObjectOfType <AudioManager> ();
        audioManager.TowerPlaced();
    }
Пример #29
0
 protected void Awake()
 {
     animatedGoblin   = transform.Find("animated");
     healthController = transform.Find("Health").GetComponent <HealthBarController>();
     animator         = animatedGoblin.GetComponent <Animator>();
     pivotArm         = transform.Find("R_arm");
     weaponArm        = transform.Find("R_arm").transform.Find("lowerarm");
     weaponHand       = transform.Find("R_arm").transform.Find("lowerarm").transform.Find("R_hand");
 }
Пример #30
0
    public void OnTriggerEnter2D(Collider2D other)
    {
        if (!other.CompareTag("Player"))
        {
            return;
        }
        Debug.Log("Tropfen TRIGGER! ");

        HealthBarController.changeHealth(-0.1f);
    }
Пример #31
0
 void Start()
 {
     _cursor = FindObjectOfType <Cursor>();
     _gameStateController = FindObjectOfType <GameStateController>();
     _shot = FindObjectOfType <Shot>();
     _healthBarController         = FindObjectOfType <HealthBarController>();
     _capsuleCollider             = GetComponent <CapsuleCollider>();
     _navMeshAgent                = GetComponent <NavMeshAgent>();
     _navMeshAgent.updateRotation = false;
 }
Пример #32
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (!other.CompareTag("Player"))
        {
            return;
        }

        HealthBarController.changeHealth(+.5f);
        Destroy(gameObject);
    }
Пример #33
0
    void Start()
    {
        GetComponent<Rigidbody2D>().velocity = Vector2.down* fallSpeed;
        dataObject = GameObject.Find("VisualizedHealthBar");
        localData = dataObject.GetComponent<HealthBarController>();

		playerObject = GameObject.FindGameObjectWithTag ("Player1").GetComponent<Player_movement> ();

		dataObject = GameObject.FindGameObjectWithTag ("ScoreText");
		score = dataObject.GetComponent<BloodCounter>();
    }
Пример #34
0
    void Start()
    {
        HP = 5;
        SCORE = 0;
        Special_Gauge = 0;

        //おまじない一覧
        rb2d = GetComponent<Rigidbody2D>();//重力
        mannekenPisAnimator = GetComponent<Animator>();//小僧のアニメーター
        HBC = GameObject.FindWithTag("HealthBar").GetComponent<HealthBarController>();//体力バー関係
        AS = GameObject.FindWithTag("Audio").GetComponent<AudioScript>();
    }
Пример #35
0
	void Start () {
		mainCamera = Camera.main;
		GameObject healthBars = GameObject.Find ("HealthBars");
		healthbarcontroller = healthBars.GetComponent<HealthBarController> ();
		transform.eulerAngles = new Vector3 (angle, 0.0f, 0.0f);
		GameObject player1Obj = GameObject.Find ("Player1");
		GameObject player2Obj = GameObject.Find ("Player2");
		player1 = player1Obj.GetComponent<PlayerController> ();
		player2 = player2Obj.GetComponent<PlayerController> ();
		anglePlus = KeyCode.I;
		angleMinus = KeyCode.K;
		xPaddingPlus = KeyCode.L;
		xPaddingMinus = KeyCode.J;
		widthMinimumPlus = KeyCode.Period;
		widthMinimumMinus = KeyCode.Comma;

		xmoment = 0.0f;
		ymoment = 0.0f;
		zmoment = 0.0f;
	}
Пример #36
0
 // Use this for initialization
 void Start()
 {
     //enemies get a health bar controller
     hbc = GetComponent<HealthBarController> ();
     //moveForward (20);
 }
Пример #37
0
 // Use this for initialization
 void Start()
 {
     MP = GameObject.FindWithTag("Player").GetComponent<Manekin_Pis>();
     HBC = GameObject.FindWithTag("HealthBar").GetComponent<HealthBarController>();//体力バー関係
     AS = GameObject.FindWithTag("Audio").GetComponent<AudioScript>();
 }
Пример #38
0
	void Awake()
	{
		instance = this;
	}
Пример #39
0
 void Awake()
 {
     Instance = this;
 }
Пример #40
0
    protected new void Start()
    {
        base.Start();

        status = StatusType.Live;

        if (showHealthBar) {
            var hb = Instantiate(Resources.Load(configs.prefabPaths.uiHealthbar),new Vector3(transform.position.x, transform.position.y - transform.lossyScale.y),Quaternion.identity) as GameObject;
            hb.transform.parent = transform;
            healthBar = hb.GetComponent<HealthBarController>();
            healthBar.setHealth(health);
            healthBar.divider = health;
            healthBar.yMargin = healthBarYMargin;
        }

        OnHit += (o) => {
            if (o.hits!=null && System.Array.IndexOf(o.hits, this.GetType()) > -1 ){
                decHealth(o.damage);
                spriteRenderer.color = Color.red;
                CancelInvoke("switchBackToOriginalColor");
                Invoke("switchBackToOriginalColor", .2f);
            }
        };

        build();
    }
Пример #41
0
        private void Start()
        {
            // get the components on the object we need ( should not be null due to require component so no need to check )
            agent = GetComponentInChildren<NavMeshAgent>();
            character = GetComponent<ThirdPersonCharacterController>();
            e = GetComponent<enemy> ();

            // set nav mesh settings
            agent.updateRotation = false;
            agent.updatePosition = true;

            // target that zombies walk to when player is found
            target = player.transform.position;

            // get the transform for the zombie's head
            head = searchTransform (transform, "Bip01 Head");

            // distance zombie will walk randomly
            distance = UnityEngine.Random.Range (50, MAX_WALKABLE_DISTANCE);

            // check state and initialize intial distance and direction for walking
            if (initialState.Equals ("alerted")) {
                anim.SetBool (initialState, true);
            } else if (initialState.Equals ("backandforth")) {
                setForward (distance);
            } else if (initialState.Equals ("random")) {
                setRandom ();
            }

            hbc = GetComponent<HealthBarController> ();
        }