Inheritance: MonoBehaviour
Example #1
0
        public override void Init()
        {
            base.Init();

            actorFx = GetComponent <AIActorFX>();
            if (actorFx != null)
            {
                actorFx.Init();
            }

            dialog = GetComponent <AIDialog>();
            if (dialog != null)
            {
                dialog.Init();
            }

            HealthUI healthUi = GetComponent <HealthUI>();

            if (healthUi != null)
            {
                healthUi.Init();
            }


            actorColider = GetComponent <Collider>();

            skilletColliders = GetComponentsInChildren <Collider>();

            SetSkilletColliderActivity(false);

            stats.onGetDamage += PushBack;
        }
Example #2
0
 private void Awake()
 {
     if (!Instance)
     {
         Instance = this;
     }
 }
Example #3
0
 public void AddHp(HealthUI healthUI)
 {
     if (m_damageable.currentHitPoints < m_damageable.maxHitPoints)
     {
         MessageBox.Show("Add HitPoints");
         m_damageable.currentHitPoints++;
         CUseHp msg = new CUseHp();
         if (TreasureInfo.playerTreasure["Elixir_3"].number == 1)
         {
             TreasureInfo.playerTreasure.Remove("Elixir_3");
             // send message
             msg.toDelete = true;
         }
         else
         {
             TreasureInfo.playerTreasure["Elixir_3"].number--;
             // send message
             msg.toDelete = false;
             msg.ownNum   = TreasureInfo.playerTreasure["Elixir_3"].number;
         }
         MyNetwork.Send(msg);
         if (inventoryHandler != null)
         {
             inventoryHandler.UpdateInventory();
         }
         healthUI.ChangeHitPointUI(m_damageable);
     }
     else
     {
         MessageBox.Show("currentHitPoints is already max");
     }
 }
Example #4
0
    public override IEnumerator Death()
    {
        //Camera stops moving
        GameObject.FindGameObjectWithTag("MainCamera").GetComponent <SimpleFollow>().following = false;
        bg.trackedObject = null;

        //Show death screen
        HealthUI.SetActive(false);
        DeathScreen.SetActive(true);

        // Appropriate death animation
        foreach (Collider2D c in GetComponents <Collider2D>())
        {
            c.enabled = false;
        }
        if (GetComponent <Rigidbody2D>())
        {
            GetComponent <Rigidbody2D>().isKinematic = true;
        }

        GetComponent <MovementController>().enabled = false;
        GetComponent <AbilityController>().enabled  = false;

        GetComponent <Animator>().SetBool("isDead", true);
        transform.localScale = new Vector3(1, 1, 1);

        yield return(0);
    }
Example #5
0
    private IEnumerator SpawnIn(HealthUI healthUI)
    {
        float t = 0f;

        Vector3 startScale = myTransform.localScale;

        while (t < popInTime)
        {
            t += Time.deltaTime;
            myTransform.localScale = Vector3.LerpUnclamped(startScale, Vector3.one, popInCurve.Evaluate(t / popInTime));

            yield return(null);
        }

        healthUI.SpawnInFinish();
        t = 0f;

        while (t < centerFillTime)
        {
            t += Time.deltaTime;
            heartFill.transform.localScale = Vector3.LerpUnclamped(startScale, Vector3.one, centerFillCurve.Evaluate(t / centerFillTime));

            yield return(null);
        }

        if (popParticle)
        {
            SimplePool.Spawn(popParticle, transform.position, Quaternion.identity);
        }
    }
Example #6
0
        private void BattleForm_Load(object sender, EventArgs e)
        {
            canvas_PB.BackgroundImage       = new Bitmap("icon/background.png");
            CheckForIllegalCrossThreadCalls = false;
            healthUI = new HealthUI();
            Agent p1 = StickMan(), p2 = StickMan();

            switch (IntroIndex)
            {
            case 1:
                p1 = AgentJ();
                break;

            case 2:
                p1 = AgentG();
                break;
            }
            switch (EnemyIntroIndex)
            {
            case 1:
                p2 = AgentJ();
                break;

            case 2:
                p2 = AgentG();
                break;
            }
            world   = new World(new Size(canvas_PB.Size.Width, canvas_PB.Size.Height), p1, p2);
            agentUI = new AgentUI(world);
            operator_Tm.Start();
            ticker_Tm.Start();
            painter_Tm.Start();
        }
    void Start()
    {
        player_anim = GetComponentInChildren <PlayerAnimation>();
        _rb         = GetComponent <Rigidbody>();
        _player     = GetComponent <Player>();
        _fsm        = new FSM <string>();

        _healthUI = gameObject.GetComponentInChildren <HealthUI>();

        IdleState <string> idle = new IdleState <string>(_fsm, player_anim, "Move", "Punch Attack", "Kick Attack");
        MoveState <string> move = new MoveState <string>(_player, _fsm, player_anim, "Attack", "Idle");
        //JumpState<string> jump = new JumpState<string>(_fsm, "Idle", _rb, _player);
        PunchAttackState <string> punchAttack = new PunchAttackState <string>(_fsm, player_anim, "Idle", "Kick Attack");
        KickAttackState <string>  kickAttack  = new KickAttackState <string>(_fsm, player_anim, "Idle", "Punch Attack");


        idle.AddTransition("Move", move);
        idle.AddTransition("Punch Attack", punchAttack);
        idle.AddTransition("Kick Attack", kickAttack);

        move.AddTransition("Idle", idle);
        move.AddTransition("Punch Attack", punchAttack);
        move.AddTransition("Kick Attack", kickAttack);

        //jump.AddTransition("Idle", idle);

        punchAttack.AddTransition("Idle", idle);
        punchAttack.AddTransition("Kick Attack", kickAttack);

        kickAttack.AddTransition("Idle", idle);
        kickAttack.AddTransition("Punch Attack", punchAttack);

        _fsm.SetInit(idle);
    }
Example #8
0
    public void AddNewHealthBar(FightUnit unit, Transform point, bool isEnemey)
    {
        if (HealthUIList.ContainsKey(unit))
        {
            return;
        }
        HealthUI healthUI = new HealthUI();

        healthUI.point = point;
        GameObject obj = Util.AddChild(isEnemey? enHealthBarObj:myHealthBarObj, mTrans);

        obj.SetActive(true);
        healthUI.displayHealthBar = obj.GetComponent <DisplayHealthBar>();
        UISprite background = obj.transform.GetChild(0).GetComponent <UISprite>();
        UISprite foreground = obj.transform.GetChild(0).GetChild(0).GetComponent <UISprite>();

        background.depth = depth++;
        foreground.depth = depth++;
        GameObject obj2 = Util.AddChild(hurtNumEmitter, mTrans);

        obj2.SetActive(true);
        healthUI.barTrans = obj.transform;
        UISlider slider = obj.GetComponentInChildren <UISlider>();

        healthUI.slider = slider;
        HurtNumEmitter emitter = obj2.GetComponent <HurtNumEmitter>();

        healthUI.emitter = emitter;
        HealthUIList.Add(unit, healthUI);
    }
Example #9
0
    private void Awake()
    {
        GameObject player = GameObject.FindGameObjectWithTag("Player");

        playerHealth  = player.GetComponent <HealthUI>();
        enemyAnimator = GetComponent <Animator>();
    }
Example #10
0
        private void InitComponents()
        {
            actorFx = GetComponent <AIActorFX>();
            if (actorFx != null)
            {
                actorFx.Init();
            }

            dialog = GetComponent <AIDialog>();
            if (dialog != null)
            {
                dialog.Init();
            }

            HealthUI healthUi = GetComponent <HealthUI>();

            if (healthUi != null)
            {
                healthUi.Init();
            }

            actorColider = GetComponent <Collider>();

            skilletColliders = GetComponentsInChildren <Collider>();
        }
Example #11
0
    void Start()
    {
        currHealth = maxHealth;
        HealthUI ui = FindObjectOfType <HealthUI>();

        ui.Add(this);
    }
Example #12
0
    public void Create(Transform target, CharactorHealth health)
    {
        HealthUI newUI = Instantiate(healthUI, target.position, Quaternion.identity);

        newUI.transform.parent = transform;
        newUI.Init(target, health);
    }
    private void CheckAttackZone()
    {
        Collider2D touchedCollider = Physics2D.OverlapBox(damageSpawnPoint.position, damageZone, 0, whomCanAttacked);
        GameObject touchedObject;

        if (touchedCollider != null)
        {
            touchedObject = touchedCollider.gameObject;
        }
        else
        {
            return;
        }
        Health   attackedObjectsHealthScripts       = touchedObject.GetComponent <Health>();
        HealthUI attackedObjectsPlayerHealthScripts = touchedObject.GetComponent <HealthUI>();

        if (attackedObjectsHealthScripts != null)
        {
            attackedObjectsHealthScripts.TakeAwayHelath(damage);
            CheckWorkProperties();
        }
        else if (attackedObjectsPlayerHealthScripts != null)
        {
            attackedObjectsPlayerHealthScripts.TakeAwayHelath(damage);
            CheckWorkProperties();
        }
        SpawnGivenDamageSFX();
        if (chechWorkWitchAnyThing)
        {
            CheckWorkProperties();
        }
    }
    public virtual void Start()
    {
        currentHealth = maxHealth;

        healthUI = GetComponent <HealthUI>();

        manaRegenFunction = GetComponent <ManaRegeneration>();
    }
Example #15
0
 /// <summary>
 /// Awake is called when the script instance is being loaded.
 /// </summary>
 void Awake()
 {
     animationScript = GetComponentInChildren <CharacterAnimation>();
     if (is_Player)
     {
         health_ui = GetComponent <HealthUI>();
     }
 }
 private void Awake()
 {
     mycharacterAnimationsScript = GetComponentInChildren <MyCharacterAnimations>();
     if (is_Player)
     {
         healthUI = GetComponent <HealthUI>();
     }
 }
Example #17
0
 void Start()
 {
     rb                  = GetComponent <Rigidbody2D>();
     attackScript        = GetComponentInChildren <Attack>();
     cameraScript        = Camera.main.GetComponent <CameraScript>();
     destroyObjectScript = GetComponentInChildren <DestroyObject>();
     healthbar           = GameObject.FindGameObjectWithTag("Healthbar").GetComponent <HealthUI>();
     playerHandScript    = GetComponentInChildren <PlayerHand>();
 }
Example #18
0
 public void DecreasePlayerHealth(float damage)
 {
     health -= damage;
     HealthUI.getInstance().updateHealthUI(health);
     if (health == 0)
     {
         GameOver();
     }
 }
Example #19
0
 void Awake()
 {
     if (instance != null)
     {
         Debug.LogError("More Than One HealthUI In Scene!");
         return;
     }
     instance = this;
 }
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.CompareTag("Pitfall"))
        {
            //gameObject.SetActive (false);
            //infoPanel.SetActive (true);
            //deathText.SetActive (true);

            //Vector3 player1 = GameObject.Find("Player1").transform.position;
            //transform.position = new Vector3 (player1.x, player1.y + 1.5f, player1.z);
            transform.position = new Vector3(spawnpoint.x, spawnpoint.y, spawnpoint.z);

            GameObject playerone    = GameObject.Find("Player1");
            HealthUI   healthaccess = playerone.GetComponent <HealthUI>();

            //decrement -=1;
            //healthaccess.health--;
            healthaccess.LoseHealth(1);

            if (healthaccess.health == 0)
            {
                playerone.SetActive(false);
                gameObject.SetActive(false);
                infoPanel.SetActive(true);
                deathText.SetActive(true);
            }
        }

        if (other.gameObject.CompareTag("Dangerous"))
        {
            GameObject playerone    = GameObject.Find("Player1");
            HealthUI   healthaccess = playerone.GetComponent <HealthUI>();
            healthaccess.LoseHealth(healthaccess.health);

            playerone.SetActive(false);
            gameObject.SetActive(false);
            infoPanel.SetActive(true);
            deathText.SetActive(true);
        }

        if (other.gameObject.CompareTag("Goal"))
        {
            //GameObject playerone = GameObject.Find("Player1");
            //Player1Controller oneaccess = playerone.GetComponent<Player1Controller>();
            //oneaccess.moveHorizontal = 0.0f;
            moveHorizontal = 0.0f;
            levelComplete  = true;
            infoPanel.SetActive(true);
            winText.SetActive(true);
        }

        if (other.gameObject.CompareTag("Checkpoint"))
        {
            spawnpoint = other.transform.position;
        }
    }
Example #21
0
 void Update()
 {
     foreach (FightUnit unit in HealthUIList.Keys)
     {
         HealthUI value = HealthUIList[unit];
         value.barTrans.position          = value.point.position;
         value.slider.value               = unit.healthValue;
         value.emitter.transform.position = value.point.position;
     }
 }
Example #22
0
 public virtual void Start()
 {
     manager        = TileManager.instance;
     myhealthUI     = GetComponent <HealthUI>();
     uIController   = UIController.instance;
     playersManager = PlayersManager.instance;
     currentTile    = GetComponentInParent <TileController>();
     SetCantMove();
     myhealthUI.OnChangeValue(unit.health);
 }
 private void PurgeManagers()
 {
     levelManager   = null;
     playerManager  = null;
     energyPizza    = null;
     healthUI       = null;
     itemInfo       = null;
     invUI          = null;
     messageManager = null;
 }
Example #24
0
    void Awake()
    {
        animationScript = GetComponentInChildren <CharacterAnimation>();

        health = maxHealth;
        if (is_Player || is_Boss)
        {
            health_UI = GetComponent <HealthUI>();
        }
    }
    void OnWizardOtherButton()
    {
        // If we have something selected
        if (Selection.activeTransform != null)
        {
            Rigidbody rigidbody = Selection.activeTransform.GetComponent <Rigidbody>();
            if (rigidbody == null)
            {
                rigidbody = Selection.activeGameObject.AddComponent <Rigidbody>();
            }
            rigidbody.useGravity  = false;
            rigidbody.constraints = RigidbodyConstraints.FreezePosition | RigidbodyConstraints.FreezeRotation;

            // TurretInit requires TurretAI which requires RangeChecker, TurretTrackingV3, Weapon
            TurretInit turretInit = Selection.activeTransform.GetComponent <TurretInit>();
            if (turretInit == null)
            {
                turretInit = Selection.activeGameObject.AddComponent <TurretInit>();
            }

            TurretTrackingV4 tracking = Selection.activeTransform.GetComponent <TurretTrackingV4>();
            if (tracking == null)
            {
                tracking = Selection.activeGameObject.AddComponent <TurretTrackingV4>();
            }
            tracking.horizontalRotation = horizontalRotation;
            tracking.verticalRotation   = verticalRotation;
            tracking.barrelRotation     = barrelRotation;

            range = Selection.activeTransform.Find("RangeChecker").GetComponent <SphereCollider>();
            RangeChecker rangeChecker = Selection.activeTransform.GetComponent <RangeChecker>();
            rangeChecker.range = range;

            healthSlider = healthSlider.GetComponent <Slider>();
            HealthUI healthUI = Selection.activeTransform.GetComponent <HealthUI>();
            healthUI.slider = healthSlider;

            Weapon weapon = Selection.activeTransform.GetComponent <Weapon>();
            weapon.projectileSpawns = projectileSpawns;

            MessageHandler messageHandler = Selection.activeTransform.GetComponent <MessageHandler>();
            if (!messageHandler.messages.Contains(MessageType.HEALTHCHANGED))
            {
                messageHandler.messages.Add(MessageType.HEALTHCHANGED);
            }
            if (!messageHandler.messages.Contains(MessageType.DAMAGED))
            {
                messageHandler.messages.Add(MessageType.DAMAGED);
            }
            if (!messageHandler.messages.Contains(MessageType.DIED))
            {
                messageHandler.messages.Add(MessageType.DIED);
            }
        }
    }
Example #26
0
 // Start is called before the first frame update
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
Example #27
0
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
         DontDestroyOnLoad(Instance);
     }
     else
     {
         Destroy(gameObject);
     }
 }
Example #28
0
        private void Start()
        {
            playerLives = maxLives;
            _healthUI   = FindObjectOfType <HealthUI>();

            if (_healthUI == null)
            {
                Debug.Log("HealthUI not found");
            }
            _healthUI.UpdateLives(playerLives);
            SetNewCheckpoint(transform);
        }
Example #29
0
    private void Awake()
    {
        _animator = GetComponentInChildren <Animator>();

        _healthUI = GetComponent <HealthUI>();
        _maxHP    = _health;

        player = GameObject.FindGameObjectWithTag("Player");
        _agent = GetComponent <NavMeshAgent>();

        //audioSource = audioSourceObject.GetComponent<AudioSource>();
    }
Example #30
0
 public void Start()
 {
     rigidbody2D     = GetComponent <Rigidbody2D>();
     animator        = GetComponent <Animator>();
     currentHealth   = maxHealth;
     timer           = changeTime;
     idleTimer       = changeTimeIdle;
     isGroundTrigger = false;
     DeathAnimSet    = false;
     if (HealthSystem != null)
     {
         HealthBar            = GetComponent <HealthUI>();
         HealthSystem.enabled = false;
     }
 }
    // Use this for initialization
    public void Init()
    {
        spot = transform.FindChild("Spotlight").GetComponent<Light>();
        player1 = GameObject.Find("Player1");
        player2 = GameObject.Find("Player2");

        p1Health = player1.GetComponent<HealthUI> ();
        p2Health = player2.GetComponent<HealthUI> ();
        wander = false;

        wanderPath2 = new PathNode[wanderPath.Length];

        for (int i = 0; i < wanderPath2.Length; i++) {
            wanderPath2[i] = new PathNode();
            wanderPath2[i].position = wanderPath[i].transform.position;
        }

        for (int i = 0; i < wanderPath2.Length; i++) {
            wanderPath2[i].next = (i+1 == wanderPath2.Length) ? wanderPath2[0]:wanderPath2[i+1];
        }

        Pursuers = new GameObject[numPursuers];

        Vector3 offset = new Vector3(pursuerOffset,0,0);
        for(int i = 0; i < numPursuers; i++){
            Pursuers[i] = (GameObject)Instantiate(Resources.Load("Prefabs/Pursuer"),transform.position+offset,Quaternion.identity);
            PursuitWrangler wrangler = Pursuers[i].GetComponent<PursuitWrangler>();
            wrangler.target = (i < numPursuers/2)?player1:player2;
            wrangler.player1 = player1;
            wrangler.player2 = player2;
            offset = (Quaternion.Euler(0,(360/numPursuers) * i,0) * offset) + new Vector3(Random.Range(0,10),0,Random.Range(0,10));
        }

        controller = GetComponent<CharacterController> ();
        fixateTarget = transform.position;

        wanderTarget = wanderPath2[6];

        spotAngleInit = spot.spotAngle;
        spotRangeInit = spot.range;

        //RandomSearch ();
    }
 // Use this for initialization
 void Start()
 {
     boss = GameObject.FindGameObjectWithTag ("Boss");
     bossHealth = boss.GetComponent<HealthUI> ();
 }
Example #33
0
    void Start()
    {
        anim = GetComponent<Animator>();
        playMove = GetComponent<PlayerMovement>();

        healthUI = GameObject.FindGameObjectWithTag("UI").GetComponent<UIController>().healthUI;

        currentHealth = fullHealth;
        healthUI.InitializeSlider(fullHealth, currentHealth);
    }
Example #34
0
 void Awake()
 {
     healthUI = GetComponentInChildren<HealthUI>();
 }
Example #35
0
 private void OnUiLoaded()
 {
     healthWidget = GameObject.FindGameObjectWithTag(Tags.HealthWidget).GetComponent<HealthUI>();
     healthWidget.gameObject.SetActive(enabled);
 }