Inheritance: MonoBehaviour
Ejemplo n.º 1
0
    void Start()
    {
        rb = GetComponent<Rigidbody2D>();

        PolygonCollider2D polygonCollider = GetComponent<PolygonCollider2D>();

        float minX = float.MaxValue;
        float maxX = float.MinValue;
        float maxY = float.MinValue;

        foreach (Vector2 point in polygonCollider.points)
        {
            if (point.x < minX) minX = point.x;
            if (point.x > maxX) maxX = point.x;
            if (point.y > maxY) maxY = point.y;
        }

        GameObject healthBarObject = new GameObject();
        healthBarObject.transform.parent = transform;
        healthBar = healthBarObject.AddComponent<HealthBar>();
        healthBar.transform.localPosition = new Vector2((maxX - minX)/2, maxY + healthBarYOffset);
        healthBar.healthBarStates = healthBarStates;
        healthBar.maxHealth = maxHealth;

        currentHealth = maxHealth;
    }
Ejemplo n.º 2
0
 void Start()
 {
     healthBar = FindObjectOfType<HealthBar>();
     staminaBar = FindObjectOfType<StaminaBar>();
     cam = FindObjectOfType<Camera>();
     body = GetComponent<Rigidbody>();
 }
Ejemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        // init the healthbar to the given amount.
        // There can be a total of 1.95 + 1.95 / 0.05 = 78 pieces of health.

        mHealthBar = GetComponentInChildren<HealthBar>();
    }
Ejemplo n.º 4
0
 void Start()
 {
     player = GameObject.FindGameObjectWithTag ("Player");
     Physics2D.IgnoreLayerCollision (11, 12);
     healthBar = GetComponentInChildren<HealthBar>();
     healthBar.Initialize(health);
 }
Ejemplo n.º 5
0
    public override void Start()
    {
        ShowTitle("FSplitSprite\nClick anywhere to change splitRatio.");

        _sprite=new FSplitSprite("Banana");
        //_sprite.splitRatio=RXRandom.Float();
        _sprite.bottomColor=Color.white;
        _sprite.topColor=Color.gray;
        _sprite.scale=2f;
        _sprite.y=40f;
        AddChild(_sprite);
        _label=new FLabel(Config.fontFile,"splitRatio=\n"+_sprite.splitRatio);
        AddChild(_label);
        _label.scale=0.5f;
        _label.y=_sprite.y-_sprite.textureRect.height*0.5f*_sprite.scaleY;

        _bar=new HealthBar(2,2,50,8,0.5f);
        //_bar.alpha=1f;
        AddChild(_bar);
        _bar.y=_label.y-20-_label.textRect.height*_label.scaleY*0.5f;

        FLabel label=new FLabel(Config.fontFile,"HealthBar by Matt");
        AddChild(label);
        label.scale=0.5f;
        label.y=_bar.y-label.textRect.height*label.scaleY*0.5f-8;

        base.Start();
    }
Ejemplo n.º 6
0
    // Use this for initialization
    public override void Start()
    {
        base.Start();

        GameObject playerGO = GameObject.Find("Player");
        player = playerGO.GetComponent<Mover>();
        playerHealth = player.GetComponent<HealthBar>();
    }
Ejemplo n.º 7
0
 // Use this for initialization
 void Start()
 {
     bar = GameObject.Find("health").GetComponent<HealthBar>();
     kid = GameObject.Find("player").GetComponent<Player>();
     beam = GameObject.Find("beam").GetComponent<Beam>();
     // score = GetComponent<Text>();
     // score.layer = 200;
 }
Ejemplo n.º 8
0
 void Awake()
 {
     //adrenalineBar = GameObject.Find("AdrenalineBar").GetComponent<AdrenalineBar> (); 
     rampageBar = GameObject.Find("RampageBar").GetComponent<RampageBar>();
     healthBar = GameObject.Find("HealthBar").GetComponent<HealthBar>();
     scoreAdd = GetComponent<AddScore>();
     spawnExplosiveBarrel = GetComponent<SpawnExplosiveBarrel>();
     screenShake = GameObject.Find("Camera").GetComponent<RandomShake>();
     sound = GameObject.Find("Handeler").GetComponent<SoundManager>();
 }
Ejemplo n.º 9
0
 void Start()
 {
     HealthBar = GameObject.Find("health").GetComponent<HealthBar>();
     Animation = GameObject.Find("PowerupText").GetComponent<Animation>();
     AnimationText = GameObject.Find("PowerupText").GetComponent<Text>();
     TimeText = GameObject.Find("PowerupTimeText").GetComponent<Text>();
     var powerupTypes = AllPowerUps().Where(IsPowerUp);
     Powerups = powerupTypes.Select(type => (PowerUp)type.GetConstructor(Type.EmptyTypes).Invoke(null)).ToArray();
     Reset();
 }
Ejemplo n.º 10
0
    void Start()
    {
        currentHealth = 100f;
        maxHealth = 100f;
        Transform tmp = Instantiate (HealthBarPrefab, transform.position, transform.rotation) as Transform;

        tmp.parent = this.transform;
        healthbar = tmp.GetComponent<HealthBar> ();
        healthbar.Reset ();
    }
Ejemplo n.º 11
0
    public void SetMaxHealth(int newMaxHealth)
    {
        maxHealth = newMaxHealth;
        health = maxHealth;

        healthBar = GetComponentInChildren<HealthBar>();
        if (healthBar) {
            healthBar.UpdateHealth(health);
        }
    }
	//public GameObject player;

	void Start()
	{
		image = GetComponent<Image> ();
		if (Instance != null) {
			DestroyImmediate(gameObject);
			return;
		}
		Instance = this;
		DontDestroyOnLoad(gameObject);
	}
    //protected Vector2 centroid_ = new Vector2(.806/8.333, 1.778/6.250);
    public PlayerCharacter(HealthBar health_bar)
        : base("huro_idle")
    {
        ListenForUpdate(HandleUpdate);

        this.health_bar_ = health_bar;

        this.scaleX = .75f;
        this.scaleY = .75f;

        this.anchorX = .243f;
        this.anchorY = .4f;

        // idle animation
        int[] idle_frames = {1, 2, 3, 4};
        FAnimation idle_animation = new FAnimation("idle", "huro_idle", idle_frames, 150, true);
        base.addAnimation(idle_animation);

        // block animation
        int[] block_frames = {1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 8, 9};
        FAnimation block_animation = new FAnimation("block", "huro_block", block_frames, 100, false);
        base.addAnimation(block_animation);

        // punch animation
        int[] punch_frames = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
        FAnimation punch_animation = new FAnimation("punch", "huro_punch", punch_frames, 100, false);
        base.addAnimation(punch_animation);

        // hit animation
        int[] hit_frames = {1, 2, 3, 4, 5, 6};
        FAnimation hit_animation = new FAnimation("hit", "huro_hit", hit_frames, 150, false);
        base.addAnimation(hit_animation);

        // walk animation
        int[] walk_frames = {1, 2, 3, 4};
        FAnimation walk_animation = new FAnimation("walk", "huro_walk", walk_frames, 150, true);
        base.addAnimation(walk_animation);

        // backwards walk animation
        int[] backwards_walk_frames = {4, 3, 2, 1};
        FAnimation backwards_walk_animation = new FAnimation("backwards_walk", "huro_walk", backwards_walk_frames, 150, true);
        base.addAnimation(backwards_walk_animation);

        // death animation
        int[] death_frames = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
        FAnimation death_animation = new FAnimation("death", "huro_death", death_frames, 150, false);
        base.addAnimation(death_animation);

        base.setDefaultAnimation("idle");

        speed_ = 0.5f;

        y = -Futile.screen.halfHeight + height/2.0f + 25.0f;
        x = -Futile.screen.halfWidth + width/2.0f + 150.0f;
    }
Ejemplo n.º 14
0
        public InterfaceBar()
        {
            Size = new Vector2f(800, 4 * 32);
            Position = new Vector2f(0, 640 - 32 * 4);
            FillColor = new Color(127, 127, 127);

            UnitPictureBox = new UnitPictureBox();
            HealthBar = new HealthBar();
            MoveButton = new MoveButton();
            AttackButton = new AttackButton();
        }
Ejemplo n.º 15
0
    void Start()
    {
        if(NotifyKillCounter)
            killCounter = GameObject.FindWithTag(KillCounterTag).GetComponent<KillCounter>();

        healthBar = this.GetComponent<HealthBar>();

        if (healthBar == null)
        {
            Debug.LogWarning("It is advised to have a HealthBar script attached to the same GameObject!");
        }
    }
Ejemplo n.º 16
0
 public void createHealthBar()
 {
     if (worldCanvas == null) {
         worldCanvas = GameObject.Find ("HealthBarCanvas");
     }
     GameObject bar = (GameObject)Instantiate (Resources.Load ("prefabs/healthBar"));
     healthBar = bar.GetComponent<HealthBar> ();
     healthBar.setMaxHealth (maxHealth);
     healthBar.transform.SetParent (worldCanvas.transform, false);
     healthBar.setAttachedObjectPos (transform.position);
     LevelDirector.instance.addMaxHealth (maxHealth);
 }
	// Use this for initialization
	void Start () {
		
		// Create our dynamic textures:
		PowerBarGraphic=new PowerBar();
		HealthBarGraphic=new HealthBar();
		
		// Internally they have now setup the dynamic://healthbar and dynamic://powerbar links for easy access from the html.
		
		// Load the UI from the above HtmlFile:
		if(HtmlFile!=null){
			UI.Html=HtmlFile.text;
		}
	}
Ejemplo n.º 18
0
 public void createHealthBar()
 {
     if (worldCanvas == null)
     {
         worldCanvas = GameObject.Find ("HealthBarCanvas");
     }
     GameObject bar = (GameObject)Instantiate (Resources.Load ("prefabs/healthBar"));
     healthBar = bar.GetComponent<HealthBar> ();
     healthBar.setColor (Color.red);
     healthBar.transform.SetParent (worldCanvas.transform, false);
     healthBar.setAttachedObjectPos (transform.position);
     healthBar.gameObject.SetActive (false);
 }
Ejemplo n.º 19
0
 public override void Enter()
 {
     base.Enter();
     guard = GetComponent<Guard>();
     hpBar = GameObject.Find("HealthBar").GetComponent<HealthBar>();
     agent = GetComponent<NavMeshAgent>();
     speed += speed / 100 * _waveStats._percentSpeed;
     dammage += dammage / 100 * _waveStats._percentDamage;
     originalSpeed = speed;
     StartCoroutine("charge");
     atackMove = false;
     //print(agent.speed);
 }
    public EnemyCharacter(HealthBar health_bar)
        : base("punchy_idle")
    {
        ListenForUpdate(HandleUpdate);

        this.health_bar_ = health_bar;

        this.anchorX = .65f;
        this.anchorY = .6f;

        // set up animations
        // -------------------

        // idle animation
        int[] idle_frames = {1, 2, 3, 4};
        FAnimation idle_animation = new FAnimation("idle", "punchy_idle", idle_frames, 150, true);
        base.addAnimation(idle_animation);

        // punch animation
        int[] punch_frames = {1, 2, 3, 4, 5, 6, 7};
        FAnimation punch_animation = new FAnimation("punch", "punchy_punch", punch_frames, 100, false);
        base.addAnimation(punch_animation);

        // taking damage animation
        int[] hit_frames = {1, 2, 3, 4, 5, 6};
        FAnimation hit_animation = new FAnimation("hit", "punchy_hit", hit_frames, 100, false);
        base.addAnimation(hit_animation);

        // blocking animation
        int[] block_frames = {1, 2, 3, 4, 5};
        FAnimation block_animation = new FAnimation("block", "punchy_block", block_frames, 100, false);
        base.addAnimation(block_animation);

        // walking animation
        int[] walk_frames = {1, 2, 3, 4};
        FAnimation walk_animation = new FAnimation("walk", "punchy_walk", walk_frames, 100, true);
        base.addAnimation(walk_animation);

        int[] backwards_walk_frames = {4, 3, 2, 1};
        FAnimation backwards_walk_animation = new FAnimation("backwards_walk", "punchy_walk", backwards_walk_frames, 100, true);
        base.addAnimation(backwards_walk_animation);

        int[] death_frames = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
        FAnimation death_animation = new FAnimation("death", "punchy_death", death_frames, 100, false);
        base.addAnimation(death_animation);

        base.setDefaultAnimation("idle");

        y = -Futile.screen.halfHeight + height/2.0f + 25.0f;
        x = Futile.screen.halfWidth - width/2.0f - 150.0f;
    }
Ejemplo n.º 21
0
	// Use this for initialization
	void Start () {
		myDefender = FindObjectOfType<Defender>();
		myHealth = myDefender.GetComponent<Health>();
		myAudioSource = myDefender.GetComponent<AudioSource>();
		if(!myAudioSource) {
			myAudioSource = myDefender.gameObject.AddComponent<AudioSource>();
		}
		
		
		myText = transform.parent.GetComponentInChildren<Text>();
		myText.text = " ";
		barLevel = Status.LEVEL0;
		damageCounter = 0;
		
		playerHealthBar = FindObjectOfType<HealthBar>();
	}
    // Use this for initialization
    void Start()
    {
        player = GameObject.FindGameObjectWithTag ("MainCamera");
        ground = GameObject.FindGameObjectWithTag ("ground");
        attack = GameObject.FindGameObjectWithTag ("attack");

        hb = player.GetComponent<HealthBar> ();
        gc = ground.GetComponent<GroundControl> ();
        sc = attack.GetComponent<SpawnScript2> ();

        ball = GameObject.Find("Attack");

        image = GameObject.FindGameObjectWithTag ("image");

        pb = image.GetComponent<progressBar> ();
        anim = GetComponent<Animator> ();
    }
	void Start () 
	{
		hasGun = false;
		hasKey = false;
		health = 1;
	
		audio.playOnAwake = false;

		pickupGUI = GameObject.Find ("GUIText_displaymessagetouser").GetComponent<DisplayMessageToUser>();
		healthBarUpdate = GameObject.Find ("healthbar").GetComponent<HealthBar>();
		guiAmmo = GameObject.Find ("GUIText_ammo");
		crosshairObject = GameObject.Find ("GUITexture_crossHair");
		gunAmmo = gameObject.GetComponent<GunBehaviour>();

		ChangeGUITexture(false, "Gun");
		ChangeGUITexture(false, "Key");
	}
Ejemplo n.º 24
0
	// Use this for initialization
	void Start () {
		maxHealth = health;
		
		levelManager = FindObjectOfType<LevelManager>();
		
		anim = GetComponent<Animator>();
		
		limitBreak = FindObjectOfType<LimitBreak>();
		
		if (GetComponent<Defender>()) {
			playerHealthBar = FindObjectOfType<HealthBar>();
			playerHealthBar.SetMaxHealth (maxHealth);
			playerHealthBar.UpdateDisplay (health);
		}
		
		scoreKeeper = GameObject.Find("Score").GetComponent<ScoreKeeper>();
		
	}
Ejemplo n.º 25
0
 void Draw(HealthBar bar)
 {
     var e = bar.renderer.bounds.extents;
     var p = Camera.main.WorldToScreenPoint (bar.transform.position + new Vector3 (-e.x, e.y, 0));
     var w = Camera.main.WorldToScreenPoint (bar.transform.position + new Vector3 (e.x, e.y, 0));
     var rect = new Rect (p.x - pixelOffset, Screen.height - p.y - pixelOffset, 0, barHeight);
     for (int i = 0; i < bar.values.Length; i++) {
         //Dont want borders? Comment out the next three lines.
         GUI.color = borderColor;
         var borderRect = new Rect (rect.x - borderSize, rect.y - borderSize, (w.x - p.x) + (borderSize * 2), rect.height + (borderSize * 2));
         GUI.DrawTexture (borderRect, baseTexture);
         GUI.DrawTexture (rect, baseTexture);
         GUI.color = colors[i % colors.Length];
         rect.width = (w.x - p.x) * bar.values[i];
         GUI.DrawTexture (rect, baseTexture);
         rect.y += barHeight + barSpacing;
     }
 }
Ejemplo n.º 26
0
	private void SetHearts(){
		float heartX = heartContainer.transform.position.x;
		float heartY = heartContainer.transform.position.y;

		turtleHeartBar = new HealthBar (Color.green, turtleMaxHealth, new Vector2(heartX, heartY), this);
		mouseHeartBar = new HealthBar (Color.blue, mouseMaxHealth, new Vector2(heartX + turtleMaxHealth, heartY), this);
		monsterHeartBar = new HealthBar (Color.red, monsterMaxHealth, new Vector2(heartX, heartY - 1), this);
	}
Ejemplo n.º 27
0
        /// <summary>
        /// Load the game from a save file
        /// </summary>
        /// <param name="currentMap">The map to load</param>
        /// <param name="score">The saved score</param>
        /// <param name="lives">The remaining number of player lives</param>
        /// <param name="player">The player last drawn on the map</param>
        /// <param name="ene">The remaining enemies on the map</param>
        /// <param name="items">The remaining items on the map</param>
        public void LoadGame(int currentMap, long score, int lives, XElement player, XElement[] ene, XElement[] items)
        {
            WorldMap            = AssetManager.LoadGameMap(currentMap, _worldView);
            Score               = score;
            NumberOfPlayerLives = lives;
            var playerAttr = player.Attributes().ToDictionary(attr => attr.Name.LocalName, attr => attr.Value);

            string[] playerName = new string[4];
            switch (playerAttr["name"])
            {
            case "Mack":
                playerName[0] = "Mack";
                playerName[1] = "Sergi";
                playerName[2] = "Trent";
                playerName[3] = "Jaun";
                break;

            case "Sergi":
                playerName[0] = "Sergi";
                playerName[1] = "Trent";
                playerName[2] = "Jaun";
                playerName[3] = "Mack";
                break;

            case "Trent":
                playerName[0] = "Trent";
                playerName[1] = "Jaun";
                playerName[2] = "Mack";
                playerName[3] = "Sergi";
                break;

            case "Juan":
                playerName[0] = "Jaun";
                playerName[1] = "Mack";
                playerName[2] = "Sergi";
                playerName[3] = "Trent";
                break;
            }
            _players = new[]
            {
                AssetManager.LoadPlayer(playerName[0], WinInstance),
                AssetManager.LoadPlayer(playerName[1], WinInstance),
                AssetManager.LoadPlayer(playerName[2], WinInstance),
                AssetManager.LoadPlayer(playerName[3], WinInstance)
            };
            for (var i = 1; i < _players.Length; i++)
            {
                _players[i].RemoveControls();
                _players[i].ResetWaitTime();
                switch (_players[i].Name)
                {
                case "Mack":
                    _players[i].EnemyICanAttack = Enemy.EnemyType.Nurse;
                    break;

                case "Sergi":
                    _players[i].EnemyICanAttack = Enemy.EnemyType.Teenager;
                    break;

                case "Trent":
                    _players[i].EnemyICanAttack = Enemy.EnemyType.FuneralHomeDirector;
                    break;

                case "Jaun":
                    _players[i].EnemyICanAttack = Enemy.EnemyType.GrimReeper;
                    break;
                }
            }
            WorldPlayer        = _players[0];
            WorldPlayer.Health = float.Parse(playerAttr["health"]);
            WorldPlayer.SetDirection(Direction.Right);
            var pos = playerAttr["position"].Split(',');

            WorldPlayer.SetPosition(new Vector2f(float.Parse(pos[0]), float.Parse(pos[1])));
            if (ene.Length > 0)
            {
                foreach (var enemy in WorldMap.EnemySpawns)
                {
                    foreach (var eneXml in ene)
                    {
                        var enePos   = eneXml.FirstAttribute.Value.Split(',');
                        var floatPos = new[] { float.Parse(enePos[0]), float.Parse(enePos[1]) };
                        if (Math.Abs(enemy.Position.X - floatPos[0]) > 0.0001f && Math.Abs(enemy.Position.Y - floatPos[1]) > 0.0001f)
                        {
                            WorldMap.EnemySpawns.Remove(enemy);
                        }
                    }
                }
                EnemiesOnMap = SpawnEnemies();
            }
            else if (ene.Length == 0)
            {
                EnemiesOnMap = new List <Enemy>();
            }
            if (items.Length > 0)
            {
                foreach (var item in WorldMap.ItemsOnMap)
                {
                    foreach (var itemXml in items)
                    {
                        var itemPos  = itemXml.FirstAttribute.Value.Split(',');
                        var floatPos = new[] { float.Parse(itemPos[0]), float.Parse(itemPos[1]) };
                        if (Math.Abs(item.Position.X - floatPos[0]) > 0.0001f && Math.Abs(item.Position.Y - floatPos[1]) > 0.0001f && item.Name.Equals(itemXml.LastAttribute.Value))
                        {
                            WorldMap.ItemsOnMap.Remove(item);
                        }
                    }
                }
            }
            else if (items.Length == 0)
            {
                WorldMap.ItemsOnMap = new List <MapItem>();
            }
            _worldView.Center = WorldPlayer.Position;
            BgColor           = WorldMap.BgColor;
            NpCsOnMap         = SpawnNpcs();
            var win = WinInstance;

            _healthBar = new HealthBar(ref win, WorldPlayer.Position);
            _scoreDisp = new ScoreDisplay(ref win, WorldPlayer.Position);
            var font = AssetManager.LoadFont("OrangeJuice");

            InitLoadText = new Text()
            {
                Position = new Vector2f(0, 0), DisplayedString = AssetManager.GetMessage(WorldMap.Name), Color = Color.Black, Font = font, CharacterSize = 60
            };
            IsInitialMapLoad = true;
            WorldPlayer.ResetWaitTime();
            foreach (var enemy in EnemiesOnMap)
            {
                enemy.ResetWaitTime();
            }
            StartWorld();
            GameMaster.IsMainMenuOpen = false;
            _displayLives             = true;
            _dispControllerTime       = true;
        }
Ejemplo n.º 28
0
 public void SetStaminaBar(HealthBar staminaBar)
 {
     this.staminaBar = staminaBar;
 }
Ejemplo n.º 29
0
    protected Unit(TeamColor _color, int _road)
    {
        gameObject      = GamePullController.CreateImage();
        gameObject.name = "Unit";

        shadow = GamePullController.CreateImage();
        shadow.GetComponent <Renderer> ().material.mainTexture = ResourcesController.Load("Textures/Shadow") as Texture;
        healthBar = new HealthBar();

        GameController.unitsDictionary.Add(gameObject, this);

        objectAnimation = new ObjectAnimation(gameObject);

        color = _color;

        roadIndex = 0;
        var     count = (color == TeamColor.Red?GameController.RoadRed.Count:GameController.RoadBlue.Count);
        Vector3 _targetPosition;

        if (color == TeamColor.Red)
        {
            if (_road == -1)
            {
                do
                {
                    roadNumber = Random.Range(0, count);
                } while (GameController.RoadRed[roadNumber].Count == 0);
            }
            else
            {
                roadNumber = _road;
            }


            _targetPosition = GameController.RoadRed[roadNumber][roadIndex];
        }
        else
        {
            if (_road == -1)
            {
                do
                {
                    roadNumber = Random.Range(0, count);
                } while (GameController.RoadBlue[roadNumber].Count == 0);
            }
            else
            {
                roadNumber = _road;
            }

            _targetPosition = new Vector3();
            try {
                _targetPosition = GameController.RoadBlue[roadNumber][roadIndex];
            } catch (System.Exception) {
                Debug.LogError(roadNumber + " " + roadIndex + "; " + GameController.RoadBlue.Count + " ");
            }
        }

        layer          = _targetPosition.z;
        targetPosition = GetTruePosition(_targetPosition);
        mapPosition    = targetPosition;
        isKilling      = false;
    }
Ejemplo n.º 30
0
        public MenuState.GameState Update(HealthBar health, bool HasDamaged)
        {
            state = Keyboard.GetState();
            if (!Over)
            {
                MediaPlayer.Pause();
                foreach (MenuObject obj in objects)
                {
                    if (obj.Rectangle.Intersects(SelecRect))
                    {
                        obj.Selected = true;
                    }
                    else
                    {
                        obj.Selected = false;
                    }
                    obj.Update();
                }

                if (state.IsKeyDown(Keys.Down) && oldstate != state)
                {
                    select.Play();
                    SelecRect.Y += (int)size.Y;
                }
                if (state.IsKeyDown(Keys.Up) && oldstate != state)
                {
                    select.Play();
                    SelecRect.Y -= (int)size.Y;
                }
            }
            if (health.Points <= 0)
            {
                objects[1].Color = Color.Gray;
                SelecRect.Y      = objects[objects.Count - 1].Rectangle.Y;
            }
            if (SelecRect.Y >= objects[objects.Count - 1].Rectangle.Y)
            {
                SelecRect.Y = objects[objects.Count - 1].Rectangle.Y;
            }
            if (SelecRect.Y <= objects[1].Rectangle.Y)
            {
                SelecRect.Y = objects[1].Rectangle.Y;
            }
            if (objects[1].Rectangle.Intersects(SelecRect) && state.IsKeyDown(Keys.Enter) && oldstate != state && CanChange)
            {
                CanChange = false;
                back.Play();
                MediaPlayer.Resume();
                return(MenuState.GameState.Playing);
            }
            if (objects[2].Rectangle.Intersects(SelecRect) && state.IsKeyDown(Keys.Enter) && oldstate != state && CanChange)
            {
                CanChange = false;
                back.Play();
                MediaPlayer.Play(MainMenu.MainMenuTheme);
                return(MenuState.GameState.MainMenu);
            }
            objects[0].Color = Color.Gainsboro;

            if (health.Points == 0)
            {
                objects[0].ObjString = "";
                over = true;
            }
            else
            {
                objects[0].ObjString = "You have: " + health.Points + " HealthPoints ";
            }
            if (over && overSound)
            {
                MediaPlayer.Play(OverTheme);
                overSound = false;
            }
            oldstate  = state;
            CanChange = true;
            return(MenuState.GameState.GameOver);
        }
Ejemplo n.º 31
0
    /**
     * Setup the entity
     */
    public void Setup(string name = _DEFAULT_NAME, float health = _DEFAULT_HEALTH, float maxHealth = _DEFAULT_MAX_HEALTH, float armor = _DEFAULT_ARMOR, float maxArmor = _DEFAULT_MAX_ARMOR, float walkSpeed = _DEFAULT_WALK_SPEED, float runSpeed = _DEFAULT_RUN_SPEED, float throwImpulseForce = _DEFAULT_THROW_IMPULSE_FORCE, HealthBar healthBar = null)
    {
        _name              = name;
        _walkSpeed         = walkSpeed;
        _runSpeed          = runSpeed;
        _throwImpulseForce = throwImpulseForce;

        _healthBar    = healthBar;
        _healthSystem = new HealthSystem(health, maxHealth, armor, maxArmor);
        _healthSystem._onHealthChanged += HandleHealthSound;
        _healthBar?.Setup(_healthSystem);
        _healthBar.gameObject.SetActive(false);
        _isLowHealthSoundPlaying = false;

        _inventory     = new Inventory(this);
        _currentWeapon = null;

        _kills = 0;
        _rank  = _DEFAULT_RANK;
    }
Ejemplo n.º 32
0
 void Start()
 {
     healthScript = GameObject.FindObjectOfType <HealthBar>();
     target       = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>();
 }
Ejemplo n.º 33
0
 void Awake()
 {
     healthcontrol  = GetComponent <HealthBar>();
     deadanimperson = GetComponent <Animator>();
 }
Ejemplo n.º 34
0
 void Start()
 {
     healthBar = HealthBar.get("boss");
     healthBar.setMaxHP(healthPool);
 }
Ejemplo n.º 35
0
 void Awake()
 {
     healthBar = GetComponent <HealthBar> ();
 }
Ejemplo n.º 36
0
 public Bunny(CombatHandler ch, HealthBar healthBar) : base(ch, healthBar)
 {
 }
Ejemplo n.º 37
0
 public override void Draw(SpriteBatch spriteBatch, Vector2 viewport)
 {
     HealthBar.Draw(spriteBatch, Location, Player.Hp);
 }
Ejemplo n.º 38
0
Archivo: Enemy.cs Proyecto: Tzook/lel
    public virtual void Hurt(ActorInstance attackSource, int damage = 0, int currentHP = 0, string cause = "attack", bool crit = false)
    {
        Anim.SetInteger("HurtType", Random.Range(0, HurtTypes));
        Anim.SetTrigger("Hurt");

        string dmgMessage = damage > 0 ? damage.ToString("N0") : "BLOCKED";

        int TextSize = 40;

        if (crit)
        {
            TextSize = 60;
        }

        switch (cause)
        {
        case "attack":
        case "world":
        case "spell":
        {
            if (crit)
            {
                AudioControl.Instance.PlayInPosition("sound_crit", attackSource.transform.position);
            }
            else
            {
                AudioControl.Instance.PlayInPosition(WoundSounds[Random.Range(0, WoundSounds.Count)], attackSource.transform.position);
            }

            if (attackSource.Info.ID == LocalUserInfo.Me.ClientCharacter.ID)
            {
                if (crit)
                {
                    PopHint("<size=" + TextSize + "> " + dmgMessage + "</size>", new Color(1f, 0.619f, 0.325f, 1f), Color.black);
                }
                else
                {
                    PopHint("<size=" + TextSize + "> " + dmgMessage + "</size>", Color.green);
                }
            }
            else
            {
                PopHint("<size=" + TextSize + "> " + dmgMessage + "</size>", Color.blue);
            }



            m_AlphaGroup.BlinkDamage();
            break;
        }

        case "aoe":
        {
            TextSize -= 15;

            AudioControl.Instance.PlayInPosition(WoundSounds[Random.Range(0, WoundSounds.Count)], attackSource.transform.position);

            if (attackSource.Info.ID == LocalUserInfo.Me.ClientCharacter.ID)
            {
                PopHint("<color=#ffff00ff><size=" + TextSize + "> " + dmgMessage + "</size></color>", Color.green, new Color(), "");
            }
            else
            {
                PopHint("<size=25>" + dmgMessage + "</size>", Color.blue, new Color(), "");
            }

            break;
        }

        case "burn":
        case "bleed":
        case "spikes":
        {
            TextSize -= 15;

            AudioControl.Instance.PlayInPosition("sound_smallHit", attackSource.transform.position);

            if (attackSource.Info.ID == LocalUserInfo.Me.ClientCharacter.ID)
            {
                PopHint("<color=#ffff00ff><size=" + TextSize + ">" + dmgMessage + "</size></color>", Color.green, new Color(), "");
            }

            break;
        }
        }



        if (!Info.isBoss)
        {
            if (m_HealthBar == null)
            {
                m_HealthBar = ResourcesLoader.Instance.GetRecycledObject("HealthBar").GetComponent <HealthBar>();
                m_HealthBar.transform.position = transform.position;
            }

            m_HealthBar.SetHealthbar(Info.CurrentHealth, currentHP, Info.MaxHealth, 2f);
        }
        else
        {
            InGameMainMenuUI.Instance.ShowBossHealthbar();
            InGameMainMenuUI.Instance.SetBossHealthbar(Info.CurrentHealth, currentHP, Info.MaxHealth, 2f);
        }

        Info.CurrentHealth = currentHP;
    }
Ejemplo n.º 39
0
 // Constructor
 protected void Awake()
 {
     healthbar = gameObject.AddComponent <HealthBar>();
     healthbar.ShowHealthBar = false;
 }
Ejemplo n.º 40
0
 void Awake()
 {
     instance = this;
 }
Ejemplo n.º 41
0
 public void SetupUI()
 {
     _healthBar = new HealthBar();
 }
Ejemplo n.º 42
0
        public override void Load()
        {
            IL.Terraria.Player.Update += Player_Update;

            Instance = this;
            Instance.Logger.Info("Another Rpg Mod " + Version + " Correctly loaded");
            JsonSkillTree.Init();
            JsonCharacterClass.Init();
            LoadedMods[SupportedMod.Thorium]  = ModLoader.GetMod("ThoriumMod") != null;
            LoadedMods[SupportedMod.Calamity] = ModLoader.GetMod("CalamityMod") != null;
            LoadedMods[SupportedMod.DBZMOD]   = ModLoader.GetMod("DBZMOD") != null;

            StatsHotKey     = RegisterHotKey("Open Stats Menu", "C");
            SkillTreeHotKey = RegisterHotKey("Open SkillTree", "X");
            ItemTreeHotKey  = RegisterHotKey("Open Item Tree", "V");
            if (!Main.dedServ)
            {
                customNPCInfo           = new UserInterface();
                NPCInfo                 = new ReworkMouseOver();
                ReworkMouseOver.visible = true;
                customNPCInfo.SetState(NPCInfo);

                customNPCName     = new UserInterface();
                NPCName           = new NPCNameUI();
                NPCNameUI.visible = true;
                customNPCName.SetState(NPCName);

                customResources   = new UserInterface();
                healthBar         = new HealthBar();
                HealthBar.visible = true;
                customResources.SetState(healthBar);

                customstats   = new UserInterface();
                statMenu      = new Stats();
                Stats.visible = false;
                customstats.SetState(statMenu);

                customOpenstats         = new UserInterface();
                openStatMenu            = new OpenStatsButton();
                OpenStatsButton.visible = true;
                customOpenstats.SetState(openStatMenu);

                customOpenST         = new UserInterface();
                OpenST               = new OpenSTButton();
                OpenSTButton.visible = true;
                customOpenST.SetState(OpenST);

                customSkillTree         = new UserInterface();
                skillTreeUI             = new SkillTreeUi();
                OpenStatsButton.visible = true;
                customSkillTree.SetState(skillTreeUI);

                customItemTree     = new UserInterface();
                ItemTreeUI         = new ItemTreeUi();
                ItemTreeUi.visible = false;
                customItemTree.SetState(ItemTreeUI);

                /*
                 *
                 * statMenu = new Stats();
                 * Stats.visible = true;
                 * customstats.SetState(statMenu);
                 */
            }
        }
Ejemplo n.º 43
0
 void Awake()
 {
     main = this;
 }
Ejemplo n.º 44
0
 protected override void AddPhases()
 {
     base.AddPhases();
     HealthBar.AddPhase(0.2f);
 }
Ejemplo n.º 45
0
 void Start()
 {
     cl_HealthBar = this;
     f_fill       = 1;
 }
Ejemplo n.º 46
0
    // Use this for initialization
    public override void Start()
    {
        if(ImmunityCombatManager.instance.stage_name.Equals("stomach"))
            level = new StomachLevel();
        else if(ImmunityCombatManager.instance.stage_name.Equals("lung"))
            level = new LungLevel();
        else
            level = new BrainLevel();
        AddChild(level);

        FSoundManager.StopMusic();
        FSoundManager.UnloadAllSoundsAndMusic();
        FSoundManager.PlayMusic("battle_music", .204f);

        FSprite enemy_headshot = new FSprite("punchy_headshot");
        enemy_headshot.x = Futile.screen.halfWidth - enemy_headshot.width/2.0f - 50.0f;
        enemy_headshot.y = Futile.screen.halfHeight - enemy_headshot.height/2.0f - 50.0f;
        enemy_healthbar_ = new HealthBar();
        enemy_healthbar_.scaleX = -.8f;
        enemy_healthbar_.x = enemy_headshot.x - enemy_headshot.width/2.0f - 25.0f;
        enemy_healthbar_.y = enemy_headshot.y;
        enemy_ = new EnemyCharacter(enemy_healthbar_);
        if(ImmunityCombatManager.instance.stage_name.Equals("lung") ||
            ImmunityCombatManager.instance.stage_name.Equals("brain"))
            enemy_.y = -Futile.screen.halfHeight*.27f;

        AddChild(enemy_);

        FSprite player_headshot = new FSprite("hero_headshot");
        player_headshot.scale = .2f;
        player_headshot.x = -Futile.screen.halfWidth + player_headshot.width/2.0f + 50.0f;
        player_headshot.y = Futile.screen.halfHeight - player_headshot.height/2.0f - 50.0f;
        player_healthbar = new HealthBar();
        player_healthbar.scaleX = .8f;
        player_healthbar.x = player_headshot.x + player_headshot.width/2.0f + 25.0f;
        player_healthbar.y = player_headshot.y;
        player_ = new PlayerCharacter(player_healthbar);
        if(ImmunityCombatManager.instance.stage_name.Equals("lung") ||
            ImmunityCombatManager.instance.stage_name.Equals("brain"))
            player_.y = -Futile.screen.halfHeight*.5f;

        playerContainer = new FContainer();
        //Debug.Log ("the player is at " + playerPosition.x + "," + playerPosition.y);

        playerContainer.AddChild (player_);

        AddChild(playerContainer);

        bacteriaContainer_ = new FContainer();
        AddChild(bacteriaContainer_);

        bubbleContainer_ = new FContainer();
        AddChild(bubbleContainer_);

        dyingBacteriaHolder_ = new FContainer();
        AddChild(dyingBacteriaHolder_);

        ImmunityCombatManager.instance.camera_.follow(playerContainer);
        AddChild(player_headshot);
        AddChild(player_healthbar);
        AddChild(enemy_headshot);
        AddChild(enemy_healthbar_);

        level_bounding_box = new Rect(-Futile.screen.halfWidth*.9f, Futile.screen.halfHeight*.9f, Futile.screen.halfWidth*1.8f, Futile.screen.halfHeight*1.8f);
    }
Ejemplo n.º 47
0
 // Start is called before the first frame update
 void Start()
 {
     hp   = GetComponent <HealthBar>();
     tape = startingAmount;
 }
Ejemplo n.º 48
0
 public EnemyController(EnemyMovement enemyMovement, Spawner spawner, HealthBar healthbar)
 {
     EnemyMovement = enemyMovement;
     Spawner = spawner;
     HealthBar = healthbar;
 }
Ejemplo n.º 49
0
 public void SetHealthBar(HealthBar healthBar)
 {
     this.healthBar = healthBar;
 }
Ejemplo n.º 50
0
        /// <summary>
        /// Setup a new game enviroment
        /// </summary>
        /// <param name="playerName">The player to load</param>
        public void NewGame(string[] playerName)
        {
            CurrentMap = 0;
            WorldMap   = AssetManager.LoadGameMap(CurrentMap, _worldView);
            _players   = new[]
            {
                AssetManager.LoadPlayer(playerName[0], WinInstance),
                AssetManager.LoadPlayer(playerName[1], WinInstance),
                AssetManager.LoadPlayer(playerName[2], WinInstance),
                AssetManager.LoadPlayer(playerName[3], WinInstance)
            };

            for (var i = 1; i < _players.Length; i++)
            {
                if (_players[i] == null)
                {
                    continue;
                }
                _players[i].RemoveControls();
                _players[i].ResetWaitTime();
                switch (_players[i].Name)
                {
                case "Mack":
                    _players[i].EnemyICanAttack = Enemy.EnemyType.Nurse;
                    break;

                case "Sergi":
                    _players[i].EnemyICanAttack = Enemy.EnemyType.FuneralHomeDirector;
                    break;

                case "Trent":
                    _players[i].EnemyICanAttack = Enemy.EnemyType.GrimReeper;
                    break;

                case "Jaun":
                    _players[i].EnemyICanAttack = Enemy.EnemyType.Teenager;
                    break;
                }
            }
            WorldPlayer = _players[0];
            WorldPlayer.SetPosition(WorldMap.PlayerInitialPosition);
            EnemiesOnMap      = SpawnEnemies();
            NpCsOnMap         = SpawnNpcs();
            _worldView.Center = WorldPlayer.Position;
            BgColor           = WorldMap.BgColor;
            StartWorld();
            var win = WinInstance;

            _healthBar = new HealthBar(ref win, WorldPlayer.Position);
            _scoreDisp = new ScoreDisplay(ref win, WorldPlayer.Position);
            var font = AssetManager.LoadFont("OrangeJuice");

            InitLoadText = new Text()
            {
                Position = new Vector2f(0, 0), DisplayedString = AssetManager.GetMessage(WorldMap.Name), Color = Color.Black, Font = font, CharacterSize = 60
            };
            IsInitialMapLoad = true;
            WorldPlayer.ResetWaitTime();
            foreach (var enemy in EnemiesOnMap)
            {
                enemy.ResetWaitTime();
            }
            _displayLives       = true;
            _dispControllerTime = true;
        }
Ejemplo n.º 51
0
        private void RunGame()
        {
            StringBuilder         temp_Word = new StringBuilder();
            Random                rand      = new Random();
            Rectangle             rect      = new Rectangle(0, 50, 800, 20);
            Rectangle             textRect;
            Font                  font          = new Font("맑은 고딕", 12);
            Graphics              g             = this.CreateGraphics();
            List <CharacterRange> charRangeList = new List <CharacterRange>();
            List <Region>         regionList    = new List <Region>();
            // Region[] regionArr;
            int x, y;
            int text_Width;
            int text_Height;

            while (true)
            {
                temp_Word.Clear();
                charRangeList.Clear();
                regionList.Clear();
                text_Width  = 0;
                text_Height = 0;
                if (Time <= 0)
                {
                    GameOver();
                    break;
                }
                if (Words.Count <= 0)
                {
                    Words = new List <string>(WordData.OrderBy(i => Guid.NewGuid()).ToList());
                }
                temp_Word.Append(Words[Words.Count - 1]);
                Words.RemoveAt(Words.Count - 1);
                using (StringFormat strFormat = new StringFormat())
                {
                    strFormat.Alignment     = StringAlignment.Center;
                    strFormat.LineAlignment = StringAlignment.Center;
                    for (int i = 0; i < temp_Word.Length; ++i)
                    {
                        charRangeList.Add(new CharacterRange(i, 1));
                    }
                    strFormat.SetMeasurableCharacterRanges(charRangeList.ToArray());
                    // regionArr = g.MeasureCharacterRanges(temp_Word.ToString(), font, rect, strFormat);
                    regionList.AddRange(g.MeasureCharacterRanges(temp_Word.ToString(), font, rect, strFormat));
                    for (int i = 0; i < temp_Word.Length; ++i)
                    {
                        // textRect = Rectangle.Round(regionArr[i].GetBounds(g));
                        textRect    = Rectangle.Round(regionList[i].GetBounds(g));
                        text_Width += textRect.Width;
                        text_Height = textRect.Height;
                    }
                }
                x = rand.Next(wnd_Rect.Width - (text_Width + 10)) + 5;
                y = 50;
                falling_Words.Add(temp_Word.ToString());
                falling_Word_Pos.Add(new Point(x, y));
                for (int i = falling_Words.Count - 1; i >= 0; --i)
                {
                    falling_Word_Pos[i] = new Point(falling_Word_Pos[i].X, falling_Word_Pos[i].Y + drop_Height);
                    if (falling_Word_Pos[i].Y + text_Height >= wnd_Rect.Height - floor_Height)
                    {
                        falling_Words.RemoveAt(i);
                        falling_Word_Pos.RemoveAt(i);
                        if (HealthBar.InvokeRequired)
                        {
                            HealthBar.Invoke(new MethodInvoker(delegate()
                            {
                                HealthBar.Value -= word_Damage;
                            }));
                        }
                        else
                        {
                            HealthBar.Value -= word_Damage;
                        }
                    }
                }
                if (HealthBar.Value <= HealthBar.Minimum)
                {
                    GameOver();
                    break;
                }
                DrawScreen();
                Thread.Sleep(drop_Cycle);
            }
        }
Ejemplo n.º 52
0
 void Start()
 {
     bar = healthBar.GetComponent <HealthBar>();
 }
Ejemplo n.º 53
0
 private void SetUpHealthBar()
 {
     _health    = maxHealth;
     _healthBar = GetComponentInChildren <HealthBar>();
     _healthBar.SetMaxHealthValue(_health);
 }
Ejemplo n.º 54
0
 public void AddHealthBar(HealthBar h)
 {
     Hbar = h;
 }
Ejemplo n.º 55
0
 // Use this for initialization
 void Start()
 {
     GameObject hpBarObj = GameObject.FindGameObjectWithTag("HPBar");
     if (hpBarObj) m_playerHealth = hpBarObj.GetComponent<HealthBar>();
 }
Ejemplo n.º 56
0
 // Start is called before the first frame update
 void Start()
 {
     hand      = transform.GetChild(1).gameObject.GetComponent <Hand>();
     foot      = transform.GetChild(2).gameObject.GetComponent <Foot>();
     healthBar = transform.GetChild(4).gameObject.GetComponent <HealthBar>();
 }
Ejemplo n.º 57
0
 private void Start()
 {
     instance = this;
     Health   = 100;
 }
Ejemplo n.º 58
0
 private void Start()
 {
     slider = GetComponent <HealthBar>();
 }
Ejemplo n.º 59
0
 // Use this for initialization
 private void Start()
 {
     Creep = new Unit(100, ArmorType.Light, 10, 5, transform.position);
     Creep.Movement.SetTarget(new Vector3(-13, 0, -1.2f));
     HealthBar = new HealthBar();
 }
Ejemplo n.º 60
0
 public virtual void Init(ContentManager _content)
 {
     this.m_healthbar = new HealthBar(_content, this);
     this.m_lp_change = new LP_Change(_content, GlobalSetting.Default.CenterField);
     this.m_numsprite = new Num(_content, Vector2.Zero, SpriteID.font_2634_dorangenum);
 }