示例#1
0
    public void RemoveEquipment(InventoryItems item, bool willEquip = false)
    {
        var equip = equipment[item.GetType().ToString()];

        if (equip == null)
        {
            return;
        }
        if (item.GetType() == typeof(Lightsource))
        {
            Lightsource temp = equip.item as Lightsource;
            CharacterStats.sightBonusFromItems -= temp.lightRadius;
        }
        else if (item.GetType() == typeof(Weapon))
        {
            References.rf.playerMovement.meleeWeapon = null;
            AnimationClip idleClip = animations.DefaultIdleClip("One_handedMelee");
            AnimationClip walkClip = animations.DefaultWalkClip("One_handedMelee");
            overrider["BaseIdle"]          = idleClip;
            overrider["BaseWalk"]          = walkClip;
            anim.runtimeAnimatorController = overrider;
            anim.SetLayerWeight(1, 1f);
        }
        else
        {
            Armor armor = item as Armor;
            if (item.GetType() == typeof(Chestgear))
            {
                foreach (var obj in chestgearEquipment)
                {
                    obj.Value.sprite = null;
                }
            }
            Info.AddDefenses(armor, true);
        }
        if (equip.obj != null)
        {
            Destroy(equip.obj);
        }
        ApplyGearEffects(equip.item, true);
        if (!willEquip)
        {
            CalculateStats();
            StartCoroutine("UpdateInventoryGear");
        }
        equip.item = null;
    }
示例#2
0
    public void DisplayDetails(InventoryItems item, bool _equipped = false)
    {
        itemName.text        = item.name;
        itemDescription.text = item.description;
        itemType.text        = item.GetType().ToString() + " - Weight " + item.weight;
        equipped.enabled     = _equipped;

        if (item is Weapon)  // WEAPONS HERE
        {
            Weapon _item = item as Weapon;
            itemType.text   = _item.hands.ToString().Replace("_", " ") + " " + _item.weaponType + " - Weight " + item.weight;
            details[0].text = $"Physical damage {TextColor.Yellow}{_item.physicalMin} {TextColor.White}-{TextColor.Yellow} {_item.physicalMax}";
            details[1].text = $"Spectral damage {TextColor.Purple}{_item.spectralMin} {TextColor.White}-{TextColor.Purple} {_item.spectralMax}";
            details[2].text = $"Fire damage {TextColor.Red}{_item.fireMin} {TextColor.White}-{TextColor.Red} {_item.fireMax}";
            details[3].text = $"Critical hit chance {TextColor.Return("yellow")}{_item.criticalHitChance}{TextColor.Return()}%";
            details[4].text = $"Attack speed {TextColor.Return("yellow")}{_item.attackRate}{TextColor.Return()} times per second";
        }
        else if (item is Lightsource)
        {
            Lightsource _item = item as Lightsource;
            details[0].text = $"Increases sight radius by {TextColor.Yellow}{_item.lightRadius}{TextColor.White} points.";
        }
        else if (item is Consumable) // CONSUMABLES HERE
        {
            Consumable _item = item as Consumable;
            for (int i = 0; i < _item.itemEffect.Length; i++)
            {
                details[i].text = ItemEffectText(_item.itemEffect[i]);
            }
        }
        else if (item is Ammo)
        {
        }
        else
        {
            Armor armor = item as Armor;
            details[0].text = $"Physical Defense {TextColor.Return("yellow")}{armor.defense}";
            details[1].text = $"Spectral Defense {TextColor.Return("purple")}{armor.spectralDefense}";
            details[2].text = $"Fire Defense {TextColor.Return("red")}{armor.fireDefense}";
        }

        CheckForGearEffects(item);
    }
示例#3
0
        public void Open(string fileName)
        {
            FrameDescription frame;
            using (var frameFile = new FileStream(fileName, FileMode.Open, FileAccess.Read))
            {
                using (var reader = new StreamReader(frameFile))
                    frame = (FrameDescription)SerializationService.Deserialize(reader.ReadToEnd(), typeof(FrameDescription));
            }

            frame.FrameName = Path.GetFileNameWithoutExtension(fileName);
            Directory.SetCurrentDirectory(frame.WorkingDir);

            scn = new SceneDescription();
            try
            {
                scn.LightOrientation = (int)frame["LightOrientation"];
            }
            catch
            {
                scn.LightOrientation = -1.0f;
            }

            scn.WorkingDirectory = frame.WorkingDir;
            scn.SceneName = frame.FrameName;
            var lights = new List<Lightsource>();
            var cameras = new List<Camera>();

            foreach (var frameElement in frame.Elements)
            {
                switch (frameElement.GetType().Name.ToString())
                {
                    case "FrameAreaLightTemplate":
                        var templ = (FrameAreaLightTemplate)frameElement;
                        scn.LightNameTemplate = templ.NameTemplate;
                        scn.LightGain = new Vector3(templ.Gain.c1, templ.Gain.c2, templ.Gain.c3);
                        break;
                    case "FrameLightsource":
                        var lt = (FrameLightsource)frameElement;
                        var light = new Lightsource();
                        if (lt.LightType == RayDen.Library.Entity.Frames.LightSourceTypes.Area)
                        {
                            var emission = Vector.FromString(lt.Parameters[FrameLightsource.LightsourcePower].ToString().Replace(" ", string.Empty));
                            light.Type = LightSourceTypes.Area;
                            light.Name = lt.Parameters[FrameLightsource.AreaLightGeometryName].ToString();
                            light.Emission = new Vector3(emission.x, emission.y, emission.z);
                        }
                        else if (lt.LightType == RayDen.Library.Entity.Frames.LightSourceTypes.EnvironmentMap)
                        {
                            light.Type = LightSourceTypes.EnvironmentMap;
                            light["ImagePath"] = scn.EnvMapPath = lt.Parameters[FrameLightsource.InfiniteLightMapPath].ToString();
                        }
                        else if (lt.LightType == RayDen.Library.Entity.Frames.LightSourceTypes.Point)
                        {
                            var pos = Vector.FromString(lt.Parameters[FrameLightsource.PointLightPosition].ToString().Replace(" ", string.Empty));
                            var emission = Vector.FromString(lt.Parameters[FrameLightsource.LightsourcePower].ToString().Replace(" ", string.Empty));
                            light.Emission = new Vector3(emission.x, emission.y, emission.z);
                            light.Type = LightSourceTypes.Point;
                            light.p0 = new Vector3(pos.x, pos.y, pos.z);
                        }
                        Trace.WriteLine(string.Format("Lightsource {0} {1}", light.Type, light.Name));
                        lights.Add(light);
                        break;
                    case "FrameCamera":
                        var cam = (FrameCamera)frameElement;

                        //cameras.Add(new Camera()
                        //{
                        //    Fov = cam.Fov > 0f ? cam.Fov : 30f,
                        //    Position = new Vector3(cam.Position.x, cam.Position.y, cam.Position.z),
                        //    Target = new Vector3(cam.Target.x, cam.Target.y, cam.Target.z),
                        //    Up = new Vector3(cam.Up.x, cam.Up.y, cam.Up.z)
                        //});

                        var camera = new Camera() { Fov = cam.Fov > 0f ? cam.Fov : 30f };
                        camera.LookAt(new Vector3(cam.Position.x, cam.Position.y, cam.Position.z),
                                      new Vector3(cam.Target.x, cam.Target.y, cam.Target.z),
                                      new Vector3(cam.Up.x, cam.Up.y, cam.Up.z));
                        cameras.Add(camera);

                        break;
                    case "FrameObjFileReference":
                        var objFile = (FrameObjFileReference)frameElement;
                        scn.SceneGeo = new GeoGroup()
                        {
                            MatFilePath = frame.WorkingDir + objFile.MtlFilePath,
                            ObjFilePath = frame.WorkingDir + objFile.ObjFilePath
                        };
                        break;
                }
            }

            scn.Cameras = cameras.ToArray();
            Trace.WriteLine(string.Format("{0} cameras", scn.Cameras.Length));
            scn.Lights = lights.ToArray();
        }
示例#4
0
    public void AddEquipment(GameObject obj, InventoryItems item)
    {
        var equip = equipment[item.GetType().ToString()];

        if (equip.item != null && equip.item.Equals(item))
        {
            return;
        }
        if (equip.item != null)
        {
            RemoveEquipment(equip.item, true);
        }
        equip.item = item;

        if (item.GetType() != typeof(Chestgear))
        {
            var srs = obj.GetComponentsInChildren <SpriteRenderer>();
            foreach (var sr in srs)
            {
                sr.material = item.material == null ? defaultMat : item.material;
            }
            if (equip.obj != null)
            {
                Destroy(equip.obj);
            }
            equip.obj = Instantiate(obj);
            if (equip.item.modifiedMat != null)
            {
                equip.obj.GetComponent <SpriteRenderer>().material = equip.item.modifiedMat;
            }
            equip.obj.transform.SetParent(equip.trans, false);
        }

        if (equip.item.GetType() == typeof(Lightsource))
        {
            Lightsource temp = equip.item as Lightsource;
            Debug.Log(equip.obj.transform.rotation);
            Weapon wep = CharacterStats.characterEquipment.weapon;
            if (wep != null)
            {
                if (wep.hands == Hands.One_handed)
                {
                    equip.obj.transform.SetParent(oneHandedLightSource, false);
                }
                else
                {
                    equip.obj.transform.SetParent(twoHandedLightSource, false);
                }
            }
            else
            {
                equip.obj.transform.SetParent(oneHandedLightSource);
            }

            CharacterStats.sightBonusFromItems += temp.lightRadius;
        }

        else if (equip.item.GetType() == typeof(Weapon))
        {
            Weapon   temp   = equip.item as Weapon;
            string   defWep = temp.weaponType == WeaponType.Melee ? "Melee" : "Ranged";
            Equipped ls     = equipment["Lightsource"];
            if (ls.obj != null)
            {
                if (temp.hands == Hands.One_handed)
                {
                    ls.obj.transform.SetParent(oneHandedLightSource, false);
                }
                else
                {
                    ls.obj.transform.SetParent(twoHandedLightSource, false);
                }
            }

            AnimationClip attackClip = temp.attackAnimation == null?animations.DefaultAttackClip(temp.hands + defWep) : temp.attackAnimation;

            AnimationClip idleClip = animations.DefaultIdleClip(temp.hands + defWep);
            AnimationClip walkClip = animations.DefaultWalkClip(temp.hands + defWep);
            overrider["BaseAttack"]        = attackClip;
            overrider["BaseIdle"]          = idleClip;
            overrider["BaseWalk"]          = walkClip;
            anim.runtimeAnimatorController = overrider;
            anim.SetLayerWeight(1, 1f);
            ParticleSystem trail = equip.obj.GetComponentInChildren <ParticleSystem>();
            if (trail != null)
            {
                References.rf.playerMovement.weaponTrailRenderer = trail;
                if (temp.weaponType == WeaponType.Melee || temp.weaponType == WeaponType.Flamethrower)
                {
                    trail.Stop();
                }
            }
            if (temp.weaponType == WeaponType.Melee)
            {
                References.rf.playerMovement.meleeWeapon = equip.obj.GetComponent <MeleeWeaponHit>();
            }
        }

        else
        {
            Armor armor = equip.item as Armor;
            if (equip.item.GetType() == typeof(Chestgear))
            {
                foreach (Transform trans in obj.transform)
                {
                    chestgearEquipment[trans.name].sprite   = trans.GetComponent <SpriteRenderer>().sprite;
                    chestgearEquipment[trans.name].material = item.material == null ? defaultMat : item.material;
                }
            }
            Info.AddDefenses(armor);
        }

        ApplyGearEffects(equip.item, false);
        CalculateStats();
        StartCoroutine("UpdateInventoryGear");
    }