예제 #1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag.Equals("Player") && !weaponType.Equals(WeaponType.BareFisted))
        {
            Puncher[] punchers = other.gameObject.GetComponentsInChildren <Puncher>();
            foreach (Puncher puncher in punchers)
            {
                if (puncher.side == Side.Right)
                {
                    puncher.PickupWeapon(weaponType);

                    if (pickupSoundPlayer != null)
                    {
                        if (weaponType.Equals(WeaponType.Bottle))
                        {
                            pickupSoundPlayer.PlaySound(SoundType.BottlePickup);
                        }
                        else
                        {
                            pickupSoundPlayer.PlaySound(SoundType.WeaponPickup);
                        }
                    }
                }
            }
            Destroy(gameObject);
        }
    }
 public override bool Equals(object obj)
 {
     if (!(obj is Weapon))
     {
         return(false);
     }
     return(weaponType.Equals((obj as Weapon).weaponType));
 }
예제 #3
0
        public void DrawOnCharacter(ModelAnimator modelAnimator, Vector3 rotation, Matrix view, Matrix projection, Vector3 position, CharacterState charState)
        {
            Matrix Model1TransfoMatrix = modelAnimator.GetAbsoluteTransform(modelAnimator.BonePoses["vincent:RightHandIndex1"].Index);

            Matrix[] Model2TransfoMatrix = new Matrix[weaponModel.Bones.Count];

            weaponModel.CopyAbsoluteBoneTransformsTo(Model2TransfoMatrix);

            Vector3 rotAxis;
            Matrix  translate;

            if (weaponType.Equals(WeaponType.Melee))
            {
                rotAxis   = new Vector3(7.5f * MathHelper.PiOver4, 2.5f * MathHelper.PiOver2, 4.5f * MathHelper.PiOver2);
                translate = Matrix.CreateTranslation(-0.16f, -0.24f, 0.8f);
            }
            else
            {
                rotAxis   = new Vector3(.5f * MathHelper.PiOver4, 2.5f * MathHelper.PiOver2, 2f * MathHelper.PiOver2);
                translate = Matrix.CreateTranslation(0f, -0.3f, 0);
            }
            rotAxis.Normalize();


            if (charState.Equals(CharacterState.FiringRifle) || charState.Equals(CharacterState.ShootRifle))
            {
                rotation.Y += 100;
            }

            Matrix tempRotation = Matrix.CreateRotationX(rotation.X)
                                  * Matrix.CreateRotationY(rotation.Y)
                                  * Matrix.CreateRotationZ(rotation.Z);

            foreach (ModelMesh mesh in weaponModel.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    Matrix model2Transform = tempRotation * Matrix.CreateRotationY(MathHelper.Pi)
                                             * Matrix.CreateTranslation(position);

                    effect.World = Matrix.CreateFromAxisAngle(rotAxis, MathHelper.Pi) * translate
                                   * Model1TransfoMatrix
                                   * model2Transform;
                    effect.View       = view;
                    effect.Projection = projection;
                }
                mesh.Draw();
            }
        }
예제 #4
0
        protected virtual void DoHit(int damage)
        {
            lastHitButtonPressed = Time.time;
            Ray ray;

            if (freeMode)
            {
                ray = m_Camera.ScreenPointToRay(input.screenPos);
            }
            else
            {
                ray = m_Camera.ViewportPointToRay(Misc.vector2half);
            }

            WeaponType wt1 = crosshairHitInfo.voxel.type.weaponType;   // Weapon that can destroy this voxel
            WeaponType wt2 = player.GetSelectedItem().item.weaponType; // Weapon that we are using


            if (!wt2.Equals(WeaponType.Any))
            {
                if (!wt2.Equals(wt1))
                {
                    return; // Don't do any damage
                }
            }
            // Check item sound
            InventoryItem inventoryItem = player.GetSelectedItem();
            if (inventoryItem != InventoryItem.Null)
            {
                ItemDefinition currentItem = inventoryItem.item;
                player.ChangeDurability(-1);
                PlayCustomSound(currentItem.useSound);
            }

            env.RayHit(ray, damage, env.buildMode ? crosshairMaxDistance : player.GetHitRange(), player.GetHitDamageRadius());
        }
예제 #5
0
        public float flintlockDelay = 1.0f;     // Delay between PreFire effects and actual Fire (with main fire effects)

        public override void OnItemLoaded(Item item)
        {
            base.OnItemLoaded(item);

            selectedType = (WeaponType)Enum.Parse(typeof(WeaponType), firearmType);

            if (selectedType.Equals(WeaponType.SemiAuto))
            {
                item.gameObject.AddComponent <Weapons.BaseFirearmGenerator>();
            }
            else if (selectedType.Equals(WeaponType.Shotgun))
            {
                item.gameObject.AddComponent <Weapons.ShotgunGenerator>();
            }

            else if (selectedType.Equals(WeaponType.TestWeapon))
            {
                item.gameObject.AddComponent <Weapons.BaseFirearmGenerator>();
            }

            else if (selectedType.Equals(WeaponType.SemiAutoLegacy))
            {
                item.gameObject.AddComponent <Legacy.SemiAutoFirearmGenerator>();
            }
            else if (selectedType.Equals(WeaponType.AutoMag))
            {
                item.gameObject.AddComponent <Legacy.AutomagGenerator>();
            }
            else if (selectedType.Equals(WeaponType.SimpleFirearm))
            {
                item.gameObject.AddComponent <Weapons.SimpleFirearm>();
            }
            else
            {
                item.gameObject.AddComponent <Weapons.BaseFirearmGenerator>();
            }
        }
예제 #6
0
    private void Buy()
    {
        List <Item> Melee;
        List <Item> Ranged;
        List <Item> Armor;
        string      Merchant;

        this.LoadWeapons(out Melee, out Ranged);
        this.LoadArmors(out Armor);

        while (true)
        {
            Console.WriteLine("Select the merchant you want to buy from");
            Console.WriteLine("1. Weapons Merchant");
            Console.WriteLine("2. Armors Merchant");
            Console.WriteLine("3. Consumables Merchant");
            Console.WriteLine("4. Return");

            Merchant = Console.ReadLine();
            Merchant = this.ParseMerchant(Merchant);

            if (Merchant.Equals("weapons"))
            {
                string WeaponType;

                Console.Clear();
                while (true)
                {
                    Console.WriteLine("Which type of weapon do you want to buy?");
                    Console.WriteLine("1. Melee");
                    Console.WriteLine("2. Ranged");
                    Console.WriteLine("3. Return");

                    WeaponType = Console.ReadLine();
                    WeaponType = this.ParseWeaponType(WeaponType);

                    Console.Clear();
                    if (WeaponType.Equals("melee"))
                    {
                        this.BuyMelee(Melee);
                        break;
                    }
                    else if (WeaponType.Equals("ranged"))
                    {
                        this.BuyRanged(Ranged);
                        break;
                    }
                    else if (WeaponType.Equals("return"))
                    {
                        break;
                    }
                    else
                    {
                        Console.WriteLine("Invalid type of weapon\n");
                    }
                }
            }
            else if (Merchant.Equals("armors"))
            {
                this.BuyArmor(Armor);
            }
            else if (Merchant.Equals("consumables"))
            {
                Console.Clear();
                Console.WriteLine("Coming soon\n");
            }
            else if (Merchant.Equals("return"))
            {
                Console.Clear();
                return;
            }
            else
            {
                Console.Clear();
                Console.WriteLine("Invalid merchant\n");
            }
        }
    }
예제 #7
0
        void LateUpdate()
        {
            if (env == null || !env.applicationIsPlaying)
            {
                return;
            }

            if (freeMode || switching)
            {
                UpdateCrosshairScreenPosition();
                forceUpdateCrosshair = true;
            }

            if (env.cameraHasMoved || forceUpdateCrosshair)
            {
                forceUpdateCrosshair = false;

                Ray ray;
                if (freeMode || switching)
                {
                    ray = m_Camera.ScreenPointToRay(input.screenPos);
                }
                else
                {
                    ray = m_Camera.ViewportPointToRay(Misc.vector2half);
                }

                // Check if there's a voxel in range
                crosshairOnBlock = env.RayCast(ray, out crosshairHitInfo, env.buildMode ? crosshairMaxDistance : VoxelPlayPlayer.instance.GetHitRange()) && crosshairHitInfo.voxelIndex >= 0;
                if (changeOnBlock)
                {
                    if (crosshairOnBlock)
                    {
                        // Puts crosshair over the voxel but do it only if crosshair won't disappear because of the angle or it's switching from orbit to free mode (or viceversa)
                        float d = -1;
                        if (crosshairHitInfo.sqrDistance > 6f)
                        {
                            d = Vector3.Dot(ray.direction, crosshairHitInfo.normal);
                        }
                        if (d < -0.2f && switchingLapsed >= 1f)
                        {
                            crosshair.position = crosshairHitInfo.point;
                            crosshair.LookAt(crosshairHitInfo.point + crosshairHitInfo.normal);
                        }
                        else
                        {
                            crosshair.localRotation = Misc.quaternionZero;
                        }
                        WeaponType wt1 = crosshairHitInfo.voxel.type.weaponType;   // Weapon that can destroy this voxel
                        WeaponType wt2 = player.GetSelectedItem().item.weaponType; // Weapon that we are using
                        crosshairMat.color = wt2.Equals(wt1) || wt2.Equals(WeaponType.Any) ? crosshairOnTargetColor : Color.red;
                    }
                    else
                    {
                        ResetCrosshairPosition();
                    }
                }
            }
            if (crosshairOnBlock)
            {
                crosshair.localScale = Misc.vector3one * (crosshairScale * (1f - targetAnimationScale * 0.5f + Mathf.PingPong(Time.time * targetAnimationSpeed, targetAnimationScale)));
                if (voxelHighlight)
                {
                    // * Faiq: Color selected vocel yellow if you can hit otherwise red.
                    WeaponType wt1 = crosshairHitInfo.voxel.type.weaponType;   // Weapon that can destroy this voxel
                    WeaponType wt2 = player.GetSelectedItem().item.weaponType; // Weapon that we are using

                    Color highlightColor = wt2.Equals(wt1) || wt2.Equals(WeaponType.Any) ? voxelHighlightColor : voxelHighlightColorR;
                    Debug.Log("(" + crosshairHitInfo.voxel.type.name + ", " + wt1.ToString() + ") | (" + wt2.ToString() + ", " + player.GetSelectedItem().item.name + ")");

                    env.VoxelHighlight(crosshairHitInfo, highlightColor, voxelHighlightEdge);
                }
            }
            else
            {
                env.VoxelHighlight(false);
            }
        }
예제 #8
0
파일: Player.cs 프로젝트: LudumDareOsd/ld45
    private void PowerLevel(int level, WeaponType type)
    {
        currentWeaponType = type;
        CleanHardpoints();
        playerRenderer.PowerLevel(level, type);

        hardPoints = new List <HardPoint>();

        switch (level)
        {
        case 0:
            break;

        case 1:
            if (type.Equals(WeaponType.Plasma))
            {
                CreateHardPoint(transform.position + new Vector3(0, 0.15f, 0), transform.rotation, bullet);
            }
            else
            {
                CreateHardPoint(transform.position + new Vector3(0, 0.15f, 0), transform.rotation, laserBullet);
            }
            break;

        case 2:
            if (type.Equals(WeaponType.Plasma))
            {
                CreateHardPoint(transform.position + new Vector3(0.09f, 0.15f, 0), transform.rotation, bullet);
                CreateHardPoint(transform.position + new Vector3(-0.09f, 0.15f, 0), transform.rotation, bullet);
            }
            else
            {
                CreateHardPoint(transform.position + new Vector3(0.09f, 0.15f, 0), transform.rotation, laserBullet);
                CreateHardPoint(transform.position + new Vector3(-0.09f, 0.15f, 0), transform.rotation, laserBullet);
            }
            break;

        case 3:
            if (type.Equals(WeaponType.Plasma))
            {
                CreateHardPoint(transform.position + new Vector3(0.3f, -0.15f, 0), transform.rotation, bullet);
                CreateHardPoint(transform.position + new Vector3(-0.3f, -0.15f, 0), transform.rotation, bullet);
                CreateHardPoint(transform.position + new Vector3(0, 0.15f, 0), transform.rotation, bullet);
            }
            else
            {
                CreateHardPoint(transform.position + new Vector3(0, 0.7f, 0), transform.rotation, laserScytheSmall, 0.5f);
            }
            break;

        case 4:
            if (type.Equals(WeaponType.Plasma))
            {
                var rightRotation = new Quaternion();
                var leftRotation  = new Quaternion();

                rightRotation.eulerAngles = new Vector3(0, 0, 25);
                leftRotation.eulerAngles  = new Vector3(0, 0, -25);

                CreateHardPoint(transform.position + new Vector3(0.3f, -0.15f, 0), leftRotation, bullet);
                CreateHardPoint(transform.position + new Vector3(-0.3f, -0.15f, 0), rightRotation, bullet);
                CreateHardPoint(transform.position + new Vector3(0.09f, 0.15f, 0), transform.rotation, bullet);
                CreateHardPoint(transform.position + new Vector3(-0.09f, 0.15f, 0), transform.rotation, bullet);
            }
            else
            {
                CreateHardPoint(transform.position + new Vector3(0, 0.7f, 0), transform.rotation, laserScytheLarge, 0.5f);
            }

            break;

        default:
            if (type.Equals(WeaponType.Plasma))
            {
                var rightRotation2 = new Quaternion();
                var leftRotation2  = new Quaternion();

                rightRotation2.eulerAngles = new Vector3(0, 0, 25);
                leftRotation2.eulerAngles  = new Vector3(0, 0, -25);

                CreateHardPoint(transform.position + new Vector3(0.3f, -0.15f, 0), leftRotation2, bullet);
                CreateHardPoint(transform.position + new Vector3(-0.3f, -0.15f, 0), rightRotation2, bullet);
                CreateHardPoint(transform.position + new Vector3(0.3f, -0.15f, 0), transform.rotation, bullet);
                CreateHardPoint(transform.position + new Vector3(-0.3f, -0.15f, 0), transform.rotation, bullet);
                CreateHardPoint(transform.position + new Vector3(0, 0.15f, 0), transform.rotation, bullet);
            }
            else
            {
                CreateHardPoint(transform.position + new Vector3(0, 0.7f, 0), transform.rotation, laserScytheLarge, 0.5f);
                CreateHardPoint(transform.position + new Vector3(0.7f, -0.3f, 0), transform.rotation, laserBullet);
                CreateHardPoint(transform.position + new Vector3(-0.7f, -0.3f, 0), transform.rotation, laserBullet);
            }

            break;
        }
    }
예제 #9
0
    public void PowerLevel(int level, WeaponType weaponType)
    {
        if (weaponType.Equals(WeaponType.Plasma))
        {
            switch (level)
            {
            case 0:
                powerRenderer.sprite = null;
                break;

            case 1:
                powerRenderer.sprite = pLevel1;
                break;

            case 2:
                powerRenderer.sprite = pLevel2;
                break;

            case 3:
                powerRenderer.sprite = pLevel3;
                break;

            case 4:
                powerRenderer.sprite = pLevel4;
                break;

            default:
                powerRenderer.sprite = pLevel5;
                break;
            }
        }
        else
        {
            switch (level)
            {
            case 0:
                powerRenderer.sprite = null;
                break;

            case 1:
                powerRenderer.sprite = pLevel1Orange;
                break;

            case 2:
                powerRenderer.sprite = pLevel2Orange;
                break;

            case 3:
                powerRenderer.sprite = pLevel3Orange;
                break;

            case 4:
                powerRenderer.sprite = pLevel4Orange;
                break;

            default:
                powerRenderer.sprite = pLevel5Orange;
                break;
            }
        }
    }