Ejemplo n.º 1
0
    private void Start()
    {
        playersMaxGold      = goldSlider.maxValue;
        playersHealth       = GetComponent <PlayersHealth>();
        playerscannonBalls  = playersMaxBalls;
        cannonBallText.text = playersMaxBalls.ToString();


        // Create Player Instances
    }
Ejemplo n.º 2
0
 public Player()
 {
     Texture              = asd.Engine.Graphics.CreateTexture2D("Resources/player.png");
     position             = new asd.Vector2DF(asd.Engine.WindowSize.X / 2.0f, asd.Engine.WindowSize.Y / 2.0f);
     Position             = position;//Positionプロパティはフィールドを通して管理する。
     sideMoveVelocity     = new asd.Vector2DF(3.0f, 0.0f);
     verticalMoveVelocity = new asd.Vector2DF(0.0f, 3.0f);
     chargeTime           = 0.0f;
     CenterPosition       = new asd.Vector2DF(Texture.Size.X / 2.0f, Texture.Size.Y / 2.0f);
     radius        = Texture.Size.Y / 2.0f;
     playersHealth = PlayersHealth.Nomal;
 }
Ejemplo n.º 3
0
 public void DefrostPlayer()
 {
     if (_playersHealth == PlayersHealth.Frozen)
     {
         _checkDefrostCount++;
         if (_checkDefrostCount > _maxFrozenCount)
         {
             _playersHealth     = PlayersHealth.Nomal;
             _checkDefrostCount = 0;
             Texture            = Texture2D.LoadStrict("Resources/player.png");
         }
     }
 }
Ejemplo n.º 4
0
 public Player(MainNode mainNode, Vector2F position) : base(mainNode, position)
 {
     Texture  = Texture2D.LoadStrict("Resources/player.png");
     doSurvey = true;
     //Position = position;
     _moveDistanceX          = new Vector2F(4.0f, 0.0f);
     _moveDistanceY          = new Vector2F(0.0f, 4.0f);
     chargeTime              = 0.0f;
     collider.Size           = Texture.Size;
     _maxBulletCountInWindow = 3;
     _hp = 10;
     _checkDefrostCount = 0;
     _maxFrozenCount    = 120;
     _playersHealth     = PlayersHealth.Nomal;
 }
Ejemplo n.º 5
0
 public override void OnCollided(CollidableObject collidableObject)
 {
     if (collidableObject is FreezeBullet)
     {
         base.OnCollided(collidableObject);
         if (playersHealth == PlayersHealth.Nomal)
         {
             this.playersHealth = PlayersHealth.Frozen;
             Texture            = asd.Engine.Graphics.CreateTexture2D("Resources/Frozenplayer.png");
         }
     }
     else
     {
         base.OnCollided(collidableObject);
         Dispose();
     }
 }
Ejemplo n.º 6
0
 protected override void OnCollide(CollidableObject collidableObject)
 {
     base.OnCollide(collidableObject);
     if (collidableObject is NomalEnemy || collidableObject is EnemyBullet)
     {
         _hp -= 1;
         if (_hp <= 0)
         {
             Parent.RemoveChildNode(this);
         }
     }
     if (collidableObject is FreezeBullet)
     {
         _playersHealth = PlayersHealth.Frozen;
         Texture        = Texture2D.LoadStrict("Resources/FrozenPlayer.png");
     }
 }
Ejemplo n.º 7
0
    void Shoot()
    {
        //Shooting Effects
        muzzelflash.Play();
        //

        //Subbtracts Ammo
        currentAmmo--;
        #region variables
        RaycastHit hit;
        #endregion

        if (Physics.Raycast(RayCenter.position, RayCenter.forward, out hit, range))
        {
            ShieldSystem shields = hit.transform.GetComponent <ShieldSystem>();

            //Relative Damage
            relativeDamage = (damage) * (Mathf.Sin((Vector3.Angle(hit.normal, GunCenter.transform.forward) * 0.5f) * Mathf.Deg2Rad));


            // Add bullet effects for every object it hits
            GameObject impactobject = Instantiate(impacteffect, hit.point, Quaternion.LookRotation(hit.normal));
            GameObject bullethole   = Instantiate(paintpoint, hit.point, Quaternion.LookRotation(hit.normal), hit.transform);

            //

            //Identifies Enemies
            GameObject side   = hit.collider.gameObject;
            Target     target = hit.transform.GetComponent <Target>();
            Debug.Log(side.tag + "   " + relativeDamage);

            Health PlayersHealth;

            if (hit.rigidbody != null)
            {
                if (hit.rigidbody.GetComponent <Health>() != null)
                {
                    PlayersHealth    = hit.rigidbody.GetComponent <Health>();
                    EnemyHealth.text = "Enemy Health :" + PlayersHealth.health.ToString();
                }
                else
                {
                    PlayersHealth = null;
                }
            }
            else
            {
                PlayersHealth = null;
            }

            HitSide.text = "Side :" + side.tag;

            //Destroys The effects
            Destroy(impactobject, 2f);
            Destroy(bullethole, 2f);
            #region Commented


            /////////////////////////////// For ricochet and penetration may work on it later delete if you dont want it
            //
            //to the top
            //        if (reflectionsRemaining == 0)
            //      {
            //        return;
            //  }


            // if (Physics.Raycast(muzzel.position, muzzel.forward, out hit, range))
            //{


            //  Gizmos.color = Color.magenta;
            // Gizmos.DrawLine(startingPosition, position);

            //  DrawPredictionReflectionPattern(position, direction, reflectionsRemaining - 1);

            //}

            #endregion

            //To destory Red Cubes when shot
            //For Testing only
            if (target != null)
            {
                target.TakeDamage(50);
            }


            // Checks if the Relative dimentions of the bullet are greater than the dimentions of the shields and if so it applies damage
            //1
            if (shields != null)
            {
                if (side.CompareTag("SideShields"))
                {
                    if (relativeDamage >= shields.SideArmor)
                    {
                        if (PlayersHealth != null)
                        {
                            PlayersHealth.TakeDamage(10);
                        }
                    }
                    else
                    {
                        Debug.Log("Hit but no damage");
                    }
                }
                //2
                if (side.CompareTag("LowerFront"))
                {
                    if (relativeDamage >= shields.LowerFrontArmor)
                    {
                        if (PlayersHealth != null)
                        {
                            PlayersHealth.TakeDamage(10);
                        }
                    }
                    else
                    {
                        Debug.Log("Hit but no damage");
                    }
                }
                //3
                if (side.CompareTag("UpperFront"))
                {
                    if (relativeDamage >= shields.UpperFrontArmor)
                    {
                        if (PlayersHealth != null)
                        {
                            PlayersHealth.TakeDamage(10);
                        }
                    }
                    else
                    {
                        Debug.Log("Hit but no damage");
                    }
                }
                //4
                if (side.CompareTag("LowerBack"))
                {
                    if (relativeDamage >= shields.LowerBackArmor)
                    {
                        if (PlayersHealth != null)
                        {
                            PlayersHealth.TakeDamage(10);
                        }
                    }
                    else
                    {
                        Debug.Log("Hit but no damage");
                    }
                }
                //5
                if (side.CompareTag("UpperBack"))
                {
                    if (relativeDamage >= shields.UpperBackArmor)
                    {
                        if (PlayersHealth != null)
                        {
                            PlayersHealth.TakeDamage(10);
                        }
                    }
                    else
                    {
                        Debug.Log("Hit but no damage");
                    }
                }
                //6
                if (side.CompareTag("CabinFront"))
                {
                    if (relativeDamage >= shields.CabinFrontArmor)
                    {
                        if (PlayersHealth != null)
                        {
                            PlayersHealth.TakeDamage(10);
                        }
                    }
                    else
                    {
                        Debug.Log("Hit but no damage");
                    }
                }
                //7
                if (side.CompareTag("CabinSide"))
                {
                    if (relativeDamage >= shields.CabinSideArmor)
                    {
                        if (PlayersHealth != null)
                        {
                            PlayersHealth.TakeDamage(10);
                        }
                    }
                    else
                    {
                        Debug.Log("Hit but no damage");
                    }
                }
                //8
                if (side.CompareTag("EngineCover"))
                {
                    if (relativeDamage >= shields.EngineCoverAarmor)
                    {
                        if (PlayersHealth != null)
                        {
                            PlayersHealth.TakeDamage(10);
                        }
                    }
                    else
                    {
                        Debug.Log("Hit but no damage");
                    }
                }
                //9
                if (side.CompareTag("Turret"))
                {
                    if (relativeDamage >= shields.TurretAarmor)
                    {
                        if (PlayersHealth != null)
                        {
                            PlayersHealth.TakeDamage(10);
                        }
                    }
                    else
                    {
                        Debug.Log("Hit but no damage");
                    }
                }
                //10
                if (side.CompareTag("TopRoof"))
                {
                    if (relativeDamage >= shields.TopRoofArmor)
                    {
                        if (PlayersHealth != null)
                        {
                            PlayersHealth.TakeDamage(10);
                        }
                    }
                    else
                    {
                        Debug.Log("Hit but no damage");
                    }
                }
                //11
                if (side.CompareTag("Buttom"))
                {
                    if (relativeDamage >= shields.ButtomArmor)
                    {
                        if (PlayersHealth != null)
                        {
                            PlayersHealth.TakeDamage(10);
                        }
                    }
                    else
                    {
                        Debug.Log("Hit but no damage");
                    }
                }
            }
        }
    }
Ejemplo n.º 8
0
 private void Start()
 {
     playersHealth = FindObjectOfType <PlayersHealth>();
 }