Exemplo n.º 1
0
    /*
     * // Update is called once per frame
     * void Update ()
     * {
     *
     * }
     */
    void StatusWindowFunc(int id)
    {
        for (int i = 0; i < (player.health / 10); i++)
        {
            GUI.DrawTexture(new Rect(xySpacing.x + (23 * i + 1), xySpacing.y + 4, 23, 23), healthBarTexture);
        }
        // GUI.Label(new Rect(xySpacing.x, xySpacing.y, 200, 18), "Health: " + (int)player.health);

        for (int i = 0; i < (player.stamina / 10); i++)
        {
            GUI.DrawTexture(new Rect(xySpacing.x + (23 * i + 1), xySpacing.y + 23, 23, 23), StaminaBarTexture);
        }
        //  GUI.Label(new Rect(xySpacing.x, xySpacing.y + 18, 200, 18), "Stamina: " + (int)player.stamina);
        GUI.Label(new Rect(xySpacing.x, xySpacing.y + 46, 200, 18), "Hunger:" + (int)player.hunger);
        GUI.Label(new Rect(xySpacing.x, xySpacing.y + 64, 200, 18), "thirst: " + (int)player.thirst);

        if (player.holdingItem != null)
        {
            GunBase holdingGun = player.holdingItem as GunBase;
            if (holdingGun != null)
            {
                GUI.Label(new Rect(xySpacing.x, xySpacing.y + 82 /*(18 * 2)*/, 200, 35), holdingGun.itemName + ": " + holdingGun.bulletsInMeg + "/" + holdingGun.bullets);
            }
        }
        GUI.DragWindow();
        // GUI.Label(new Rect(xySpacing.x, xySpacing.y + (16 * 2), 200, 35), "Bullets: " + (player.holdingGun.bulletsInMeg + player.holdingGun.bullets));
    }
    /// <summary>
    /// Starts the effect by assigning the invisibility material to the player.
    /// </summary>
    protected override void InitEffect()
    {
        // Since this effect transitions (LERPs) from the base player model
        // shader to the invisibility refraction shader, we init the LERP
        // value to zero to start the transition going from the base player
        // model to the refraction effect.
        mInvisibilityMaterial.SetFloat("_RefractionEffectLerp", 0.0f);

        // Apply the invisibility material to the player model
        mPlayer.PlayerMeshRenderer.material = mInvisibilityMaterial;

        // Keep track of the equipped weapon. We'll detect when the weapon
        // changes so we can apply the invisibility effect to the new/changed
        // weapon also
        mEquippedWeapon = mPlayer.WeaponManager.CurrentWeapon;
        ApplyInvisibilityToWeapon(mEquippedWeapon);

        // Listen for weapon fires
        mShotFired += OnShotFired;
        mPlayer.WeaponManager.RegisterInstantShotFiredCallback(mShotFired);
        mPlayer.WeaponManager.RegisterExplosiveShotFiredCallback(mShotFired);
        mPlayer.WeaponManager.RegisterKineticShotFiredCallback(mShotFired);
        mPlayer.WeaponManager.RegisterSpreadShotFiredCallback(mShotFired);

        // Listen for player taking damage
        mPlayer.ShieldHealthManager.mOnDamageTaken += OnDamageTaken;

        // Visually lerp the effect in
        mExposeStartTime = Time.time;
        mExposeDuration  = mVisualLerpDuration;
    }
Exemplo n.º 3
0
    public void GetGun(string id)
    {
        if (isDead)
        {
            return;
        }
        GunBase newGun = Instantiate(ObjectData.instance.guns[id], transform.position, Quaternion.identity, hand);

        newGun.transform.localPosition = newGun.transform.localEulerAngles = Vector3.zero;
        gunInventory[0].gameObject.SetActive(false);

        //if (gunInventory[1] != null)
        //{
        //    Rigidbody newItem = Instantiate(ObjectData.instance.items[gunInventory[1].id.Split('(')[0] + "Item"], transform.position + Vector3.up * 0.5f, Quaternion.identity).GetComponent<Rigidbody>();
        //    newItem.AddForce(Vector3.up * 5, ForceMode.Impulse);
        //    Destroy(gunInventory[1].gameObject);
        //}
        if (gunInventory[1] != null)
        {
            Destroy(gunInventory[1].gameObject);
        }
        gunInventory[1] = newGun;
        nowGun          = gunInventory[index = 1];

        SetGunInfo();
    }
Exemplo n.º 4
0
    // When the player dies:
    // - Drop inventory items
    // - Reset multiplier
    // - Decrement lives
    // - Trigger events so any message subscribers can react
    //
    public uint OnPlayerHasDied()
    {
        m_bPlayerMarkedForDeath = false;

        LockPlayer();

        // Create the explosion
        Instantiate(m_goExplosionEffect, transform.position, Quaternion.identity);

        // Check for achievement
        ++m_iNumberOfDeaths;
        if (m_iNumberOfDeaths > 200)
        {
            GameMode.AchievementUnlocked(Types.EAchievementIdentifier._SweetBangBang);
        }
        else
        {
            Debug.Log("Sweet Bang Bang count: " + m_iNumberOfDeaths);
        }


        // Handle Inventory
        {
            GAssert.Assert(null != m_gcInventory, "Player Inventory not set!");
            if (m_bCanDrop)
            {
                m_gcInventory.DropInventory();
                m_gcInventory.GetPlayerOption().SetActive(false);
            }
            m_gcEquippedWeapon     = m_gcInventory.GetEquippedWeapon();
            m_fCachedMovementSpeed = m_fPlayerMovementSpeed + (m_fPlayerMovementSpeedPowerUp * m_gcInventory.GetSpeedMultiplier());
        }


        // Update state
        {
            m_bIsAlive         = false;
            m_iScoreMultiplier = 1;
            if (m_iLives > 0)
            {
                --m_iLives;
            }
        }

        // Tell the HUD things have changed...
        Messenger.Invoke(Types.s_sHUD_LivesUpdated);
        Messenger.Invoke(Types.s_sHUD_MultiplierUpdated);


        // Check for the achievement
        if (GameInstance.Object.m_bIsCecconoid && m_bIsFirstDeath)
        {
            GameMode.AchievementUnlocked(Types.EAchievementIdentifier._FirstDeath);
            m_bIsFirstDeath = false;
        }

        // Return lives count. GameMode / GameInstance decide what to do when the
        // player is out of lives.
        return(m_iLives);
    }
Exemplo n.º 5
0
 public void Switch(int direction)
 {
     if (direction == 0)
     {
         return;
     }
     if (Guns.Count <= 1)
     {
         return;
     }
     if (EquippedGun == null)
     {
         EquippedGun = Guns [0];
         EquippedGun.OnEquip(gameObject);
         EquippedGun.equipped = true;
         return;
     }
     EquippedGun.equipped = false;
     EquippedGun.OnUnequip(gameObject);
     // Oh my god % is not actually modulo. Why would you do this C#???
     //EquippedGun = Guns [(Guns.IndexOf(EquippedGun)+direction)%Guns.Count];
     EquippedGun = Guns [(int)Helper.fmod(Guns.IndexOf(EquippedGun) + direction, Guns.Count)];
     EquippedGun.OnEquip(gameObject);
     EquippedGun.equipped = true;
 }
Exemplo n.º 6
0
 private void OnTriggerExit(Collider other)
 {
     if (other.tag == "Gun" && other.GetComponent <GunBase>() != null && gunToEquip == other.GetComponent <GunBase>())
     {
         gunToEquip = null;
     }
 }
Exemplo n.º 7
0
        public override void Init(MyObjectBuilder_EntityBase objectBuilder)
        {
            m_handItemDefinitionId = objectBuilder.GetId();
            m_physItemDef          = MyDefinitionManager.Static.GetPhysicalItemForHandItem(m_handItemDefinitionId);
            base.Init(objectBuilder);
            Init(null, PhysicalItemDefinition.Model, null, null, null);

            Save = false;

            PhysicalObject                    = MyObjectBuilderSerializer.CreateNewObject <MyObjectBuilder_PhysicalGunObject>(m_handItemDefinitionId.SubtypeName);
            PhysicalObject.GunEntity          = (MyObjectBuilder_EntityBase)objectBuilder.Clone();
            PhysicalObject.GunEntity.EntityId = this.EntityId;

            m_toolItemDef = PhysicalItemDefinition as MyToolItemDefinition;

            m_notEnoughStatNotification = new MyHudNotification(MyCommonTexts.NotificationStatNotEnough, disappearTimeMs: 1000, font: MyFontEnum.Red, level: MyNotificationLevel.Important);

            InitToolComponents();

            NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME | MyEntityUpdateEnum.EACH_10TH_FRAME;

            var builder = objectBuilder as MyObjectBuilder_HandToolBase;

            if (builder.DeviceBase != null)
            {
                GunBase.Init(builder.DeviceBase);
            }
        }
Exemplo n.º 8
0
    private void Awake()
    {
        playerTr = transform;
        muzzle   = transform.GetChild(1);
        rb       = transform.GetComponent <Rigidbody>();
        animator = transform.GetChild(0).GetComponent <Animator>();

        coinText = GameObject.Find("CoinText").GetComponent <Text>();

        bulletCountText = GameObject.Find("BulletInfo").GetComponent <Text>();

        if (canAttack)
        {
            Transform healthTr = GameObject.Find("Health").transform;
            hearts = new Image[healthTr.childCount];
            for (int i = 0; i < healthTr.childCount; i++)
            {
                hearts[i] = healthTr.GetChild(i).GetComponent <Image>();
            }
            maxHealthPoint = healthPoint = healthTr.childCount * 2;

            nowGun = gunInventory[0];
        }
        Transform gunUIParent = GameObject.Find("Gun").transform;

        gunUI = new GameObject[gunUIParent.childCount];
        for (int i = 0; i < gunUIParent.childCount; i++)
        {
            gunUI[i] = gunUIParent.GetChild(i).gameObject;
        }
    }
Exemplo n.º 9
0
    // Use this for initialization
    void Start()
    {
        currentGun = guns[Random.Range(0, 3)];
        GameObject aux = Instantiate(currentGun.gunPrefab, gunPoint.position, transform.rotation) as GameObject;

        aux.transform.SetParent(this.transform);
    }
Exemplo n.º 10
0
    void OnGUI()
    {
        for (int i = 0; i < (player.health / 10); i++)
        {
            GUI.DrawTexture(new Rect((23 * i + 1), Screen.height - (23 * 2), 23, 23), healthBarTexture);
        }
        // GUI.Label(new Rect(xySpacing.x, xySpacing.y, 200, 18), "Health: " + (int)player.health);

        for (int i = 0; i < (player.stamina / 10); i++)
        {
            GUI.DrawTexture(new Rect((23 * i + 1), Screen.height - 23, 23, 23), StaminaBarTexture);
        }

        //GUI.Label(new Rect(xySpacing.x, xySpacing.y + 18, 200, 18), "Stamina: " + (int)player.stamina);


        GUI.Label(new Rect(0, Screen.height - (23 * 3), 200, 23), "Hunger:" + (int)player.hunger);
        GUI.Label(new Rect(0, Screen.height - (23 * 4), 200, 23), "thirst: " + (int)player.thirst);

        if (player.holdingItem != null)
        {
            GunBase holdingGun = player.holdingItem as GunBase;
            if (holdingGun != null)
            {
                GUI.Label(new Rect(0, Screen.height - (23 * 5), 200, 35), holdingGun.itemName + ": " + holdingGun.bulletsInMeg + "/" + holdingGun.bullets);
            }
        }
    }
Exemplo n.º 11
0
 public void SetTargetGun(GunBase gun)
 {
     if (gun != null)
     {
         _gun = gun;
     }
 }
Exemplo n.º 12
0
    // Update is called once per frame
    protected override void Update()
    {
        UpdateActions();
        if (mouseLook.isEnabled)
        {
            if (canMove)
            {
                UpdateMovement();
            }

            if (Input.GetMouseButtonDown(1))
            {
                if (holdingItem != null)
                {
                    GunBase holdingGun = holdingItem as GunBase;
                    if (holdingGun != null)
                    {
                        holdingGun.Zoom(crossHair);
                    }
                }
            }
            if (Input.GetMouseButtonUp(1))
            {
                Camera.main.fieldOfView = startFov;
                crossHair.ResetCrosshair();
                mouseLook.sensitivityX = 15;
                mouseLook.sensitivityY = 15;
            }
        }
        base.Update();
    }
Exemplo n.º 13
0
 private void OnTriggerStay2D(Collider2D collision)
 {
     if (collision.tag == "Gun")
     {
         GunToPickUp = collision.GetComponentInParent <GunBase>();
     }
 }
Exemplo n.º 14
0
 private void OnTriggerEnter(Collider other)
 {
     //Gun to equip
     if (other.tag == "Gun" && other.GetComponent <GunBase>() != null)
     {
         gunToEquip = other.GetComponent <GunBase>();
     }
 }
Exemplo n.º 15
0
        public override MyObjectBuilder_EntityBase GetObjectBuilder(bool copy = false)
        {
            var ob = base.GetObjectBuilder(copy) as MyObjectBuilder_HandToolBase;

            ob.SubtypeName = m_handItemDefinitionId.SubtypeName;
            ob.DeviceBase  = GunBase.GetObjectBuilder();
            return(ob);
        }
Exemplo n.º 16
0
 public override void Init()
 {
     key   = KeyNum.Skill1;
     time  = new FixedNumber(0.7f);
     timer = new FixedNumber(0);
     gun   = new GunBase();
     gun.Init(20, data);
 }
Exemplo n.º 17
0
 // Start is called before the first frame update
 void Start()
 {
     m_rb             = GetComponent <Rigidbody>();
     m_base           = GetComponent <GunBase>();
     m_nowWepone      = AttackType.Gun;
     m_isCursor       = false;
     Cursor.visible   = false;
     Cursor.lockState = CursorLockMode.Locked;
 }
Exemplo n.º 18
0
 private void FixedUpdate()
 {
     GunToPickUp        = null;
     transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(0, 0, Angle), Time.fixedDeltaTime * RotationSpeed);
     if (Mathf.Abs(Mathf.DeltaAngle(transform.eulerAngles.z, Angle)) < 5)
     {
         transform.rotation = Quaternion.Euler(0, 0, Angle);
     }
 }
Exemplo n.º 19
0
 void Start()
 {
     gunList = new GunBase[DataManager.instance.gunTypes.Length];
     for (int i = 0; i < DataManager.instance.gunTypes.Length; i++)
     {
         gunList[i] = GunBase.Build(DataManager.instance.gunTypes[i], gameObject);
     }
     gunIndex = Mathf.Clamp(startGunIndex, 0, gunList.Length - 1);
     health   = GetComponent <PlayerHealth>();
 }
Exemplo n.º 20
0
    public bool AddPowerUp(Types.EPowerUp iPowerUp)
    {
        GAssert.Assert(null != m_gcInventory, "Player Inventory not set!");

        // Set the inventory state for the new pickup
        switch (iPowerUp)
        {
        case Types.EPowerUp._SHOT_DOUBLE: m_gcInventory.SetInventoryItem(Types.s_iINV_Shot_Double); break;

        case Types.EPowerUp._SHOT_TRIPLE: m_gcInventory.SetInventoryItem(Types.s_iINV_Shot_Triple); break;

        case Types.EPowerUp._LASER_SINGLE: m_gcInventory.SetInventoryItem(Types.s_iINV_Laser_Single); break;

        case Types.EPowerUp._LASER_DOUBLE: m_gcInventory.SetInventoryItem(Types.s_iINV_Laser_Double); break;

        case Types.EPowerUp._LASER_TRIPLE: m_gcInventory.SetInventoryItem(Types.s_iINV_Laser_Triple); break;

        case Types.EPowerUp._OPTION: m_gcInventory.SetInventoryItem(Types.s_iINV_Option); break;

        case Types.EPowerUp._SPEED1: m_gcInventory.SetInventoryItem(Types.s_iINV_Speed1); break;

        case Types.EPowerUp._SPEED2: m_gcInventory.SetInventoryItem(Types.s_iINV_Speed2); break;
        }

        // Update the weapon, in case we've upgraded...
        if (m_gcEquippedWeapon != m_gcInventory.GetEquippedWeapon())
        {
            m_gcEquippedWeapon.SetCanFire(false);
            m_gcEquippedWeapon = m_gcInventory.GetEquippedWeapon();
        }

        // Update the cached speed multiplier
        m_fCachedMovementSpeed = m_fPlayerMovementSpeed + (m_fPlayerMovementSpeedPowerUp * m_gcInventory.GetSpeedMultiplier());

        // If this was the option, enable it!
        if (iPowerUp == Types.EPowerUp._OPTION)
        {
            m_gcInventory.GetPlayerOption().SetActive(true);
        }

        // In Eugatron pickups give you a little invulnerable period...
        if (!GameInstance.Object.m_bIsCecconoid && !m_bIsGod)
        {
            StartInvulnerablePeriod();
        }

        // Check for Achievement
        if (m_gcInventory.IsFullPower() && GameInstance.Object.m_bIsCecconoid)
        {
            GameMode.AchievementUnlocked(Types.EAchievementIdentifier._FullPowerCecconoid);
        }

        // We've always added something...
        return(true);
    }
Exemplo n.º 21
0
    // Use this for initialization
    void Start()
    {
        guns = new GunBase[2];
        GameObject gun1 = Instantiate <GameObject>(Resources.Load <GameObject>("Prefab/Gun/Gun_" + RoomSingle.GetInfos()[ib.IP].gun1ID + "_AI"));

        guns[0] = gun1.GetComponent <GunBase>();
        GameObject gun2 = Instantiate <GameObject>(Resources.Load <GameObject>("Prefab/Gun/Gun_" + RoomSingle.GetInfos()[ib.IP].gun2ID + "_AI"));

        guns[1] = gun2.GetComponent <GunBase>();
        base.BaseStart();
    }
Exemplo n.º 22
0
 private void Start()
 {
     currentTargets      = GetComponent <FieldOfView>().visibleTargets;
     currentGun          = GetComponentInChildren <GunBase>();
     soldierNavMeshAgent = GetComponent <NavMeshAgent>();
     animationSoldier    = GetComponentInChildren <Animation_Soldier>();
     if (guiMessageText != null)
     {
         guiMessageText = GameObject.Find("MessageText").GetComponent <GUIMessageText>();
     }
 }
Exemplo n.º 23
0
 private void ReloadGun()
 {
     if (holdingItem != null && MOVER_FLAGS.isReloading)
     {
         if (holdingItem.GetType().ToString() == "GunBase")
         {
             GunBase holdingGun = holdingItem as GunBase;
             holdingGun.Reload();
             MOVER_FLAGS.isReloading = false;
         }
     }
 }
Exemplo n.º 24
0
 // Use this for initialization
 void Start()
 {
     client = new BattlePlayerClient();
     base.BaseStart();
     myRotation.y         = transform.rotation.eulerAngles.y;
     watchPointRotation.x = watchPoint.rotation.eulerAngles.x;
     watchPointRotation.y = watchPoint.rotation.eulerAngles.y;
     gunAngle             = watchPointRotation.x;
     Cursor.visible       = false;                 //控制鼠标显示和隐藏, true显示, false时隐藏
     Cursor.lockState     = CursorLockMode.Locked; //把鼠标锁定在窗口内,防止鼠标拖到边缘是显示
     gun = currentGun;
 }
Exemplo n.º 25
0
    private void Awake()
    {
        thisRb        = GetComponent <Rigidbody>();
        camController = GetComponent <PlayerCameraController>();
        thisAnimator  = GetComponent <Animator>();
        gun           = GetComponent <GunBase>();

        mainCam = Camera.main;
        sprintEffect.emitting = false;

        sprintAnimHash = Animator.StringToHash("isSprinting");
        crouchAnimHash = Animator.StringToHash("isCrouching");
    }
Exemplo n.º 26
0
 public void SetGun(GunBase newGun = null)
 {
     if (newGun == null)
     {
         ready            = false;
         gun              = null;
         gunSprite.sprite = null;
         return;
     }
     gun = newGun;
     gunSprite.sprite = newGun.sprite;
     ready            = true;
 }
Exemplo n.º 27
0
 public override void Awake()
 {
     base.Awake();
     camera.enabled = false;
     for (int i = 0; i < guns.Length; i++)
     {
         var a = guns[i];
         a.arrayId = i;
         a.SetActive(false);
         a.pl = this;
     }
     gun = guns[0];
     gun.SetActive(true);
     enabled = false;
     print("Player Awake " + id);
 }
Exemplo n.º 28
0
    void updateWeaponInfo()
    {
        if (player.Inventory.Count > 0)
        {
            GunBase temp = player.Inventory[player.CurrentWeapon];

            if (!temp.IsReloading)
            {
                weaponInfoText.text = temp.gunName + ": " + temp.ClipAmmo + "/" + temp.Ammo;
            }
        }
        else
        {
            weaponInfoText.text = "";
        }
    }
Exemplo n.º 29
0
    // Update is called once per frame
    void Update()
    {
        for (int i = 0; i < guns.Length; i++)
        {
            GunBase gun = guns [i];
            Text    tex = texts [i];
            Image   im  = backdropImages[i];

            Color c = im.color;
            c.g = (guns[i].IsActiveGun())? 120.0f / 255.0f : (gun.Unlocked() ? 60.0f / 255.0f : 43.0f / 255.0f);
            //Debug.Log ("i " + i + " c.g " + c.g);
            im.color = c;

            tex.text = gun.GetGunName() + "\n" + (gun.Unlocked() ? "Unlocked" : "Unlocks at " + gun.UnlockKillCount());
        }
    }
Exemplo n.º 30
0
    private void TakeGun(GunBase gun)
    {
        var rb = gun.GetComponent <Rigidbody>();

        if (rb != null)
        {
            rb.detectCollisions = false;
            rb.isKinematic      = true;
        }
        gun.transform.SetPositionAndRotation(gunPoint.position, gunPoint.rotation);
        gun.transform.parent = gunPoint;
        gun.playerNumber     = playerNumber;
        gun.playerRigidbody  = bodyRigidbody;

        equippedGun = gun;
    }
Exemplo n.º 31
0
 public override void Awake()
 {
     base.Awake();
     camera.enabled = false;
     for (int i = 0; i < guns.Length; i++)
     {
         var a = guns[i];
         a.arrayId = i;
         a.SetActive(false);
         a.pl = this;
     }
     gun = guns[0];
     gun.SetActive(true);
     enabled = false;
     print("Player Awake " + id);
 }
Exemplo n.º 32
0
 public void SelectGun(int i)
 {
     if (guns[i].gunId == 5 && guns[i].patrons == 0)
         i = 0;
     if (gun.arrayId != i)
     {
         var g = guns[i];
         foreach (var g2 in guns)
             g2.SetActive(false);
         g.SetActive(true);
         gun = g;
     }
 }