Exemplo n.º 1
0
        public static void Callback(Mobile from, object target, object craftState)
        {
            string     errorMessage = null;
            CraftState cs           = craftState as CraftState;

            try
            {
                if (target is BaseWeapon)
                {
                    SpellCraft.ApplyAttribute(from, cs.Book, cs.Id, (BaseWeapon)target, AosWeaponAttribute.HitLowerDefend, m_Minimum, m_Maximum, 2);
                }

                else
                {
                    errorMessage = SpellCraft.AssembleMessage(SpellCraft.MsgNums.Weapons);
                }
            }
            catch (SpellCraftException e)
            {
                errorMessage = e.ToString();
            }
            finally
            {
                if (null != errorMessage)
                {
                    from.SendMessage(errorMessage);
                }
            }
        }
Exemplo n.º 2
0
    void ActiveState(CraftState state)
    {
        if (meshRender == null)
        {
            Debug.LogError("mesh renderer missing"); return;
        }
        tweenState.Rewind(false);
        tweenState.Play().OnPlay(delegate {
            switch (state)
            {
            case CraftState.attack:
                matBlock.SetColor("_StateColor", attackStateColor);
                break;

            case CraftState.isHit:
                matBlock.SetColor("_StateColor", isHitStateColor);
                break;

            default:
                break;
            }
        }).OnUpdate(delegate {
            //Debug.LogWarning("stateIns");
            matBlock.SetFloat("_StateIntensity", stateIns);
            if (meshRender != null)
            {
                meshRender.SetPropertyBlock(matBlock);
            }
        }).OnComplete(delegate {
            tweenState.Rewind();
        });
    }
Exemplo n.º 3
0
        public static void Callback(Mobile from, object target, object craftState)
        {
            string     errorMessage = null;
            CraftState cs           = craftState as CraftState;

            try
            {
                if (target is BaseWeapon)
                {
                    SpellCraft.ApplySlayerAttribute(from, cs.Book, cs.Id, (BaseWeapon)target);
                }

                else if (target is BaseInstrument)
                {
                    SpellCraft.ApplySlayerAttribute(from, cs.Book, cs.Id, (BaseInstrument)target);
                }

                else
                {
                    errorMessage = SpellCraft.AssembleMessage(SpellCraft.MsgNums.Weapons, SpellCraft.MsgNums.AndInstruments);
                }
            }
            catch (SpellCraftException e)
            {
                errorMessage = e.ToString();
            }
            finally
            {
                if (null != errorMessage)
                {
                    from.SendMessage(errorMessage);
                }
            }
        }
Exemplo n.º 4
0
        public static void Callback(Mobile from, object target, object craftState)
        {
            string     errorMessage = null;
            CraftState cs           = craftState as CraftState;

            try
            {
                if (target is BaseArmor)
                {
                    SpellCraft.ApplyAttribute(from, cs.Book, cs.Id, (BaseArmor)target, AosAttribute.ReflectPhysical, m_Minimum, m_Maximum);
                }

                else if (target is BaseHat)
                {
                    SpellCraft.ApplyAttribute(from, cs.Book, cs.Id, (BaseHat)target, AosAttribute.ReflectPhysical, m_Minimum, m_Maximum);
                }

                else
                {
                    errorMessage = SpellCraft.AssembleMessage(SpellCraft.MsgNums.ArmorComma, SpellCraft.MsgNums.ShieldsComma, SpellCraft.MsgNums.AndHats);
                }
            }
            catch (SpellCraftException e)
            {
                errorMessage = e.ToString();
            }
            finally
            {
                if (null != errorMessage)
                {
                    from.SendMessage(errorMessage);
                }
            }
        }
Exemplo n.º 5
0
        public static void Callback(Mobile from, object target, object craftState)
        {
            string     errorMessage = null;
            CraftState cs           = craftState as CraftState;

            try
            {
                if (target is BaseShield)
                {
                    SpellCraft.ApplyAttribute(from, cs.Book, cs.Id, (BaseShield)target, AosAttribute.SpellChanneling, m_Minimum, m_Maximum);
                    SpellCraft.AdjustFastCast((BaseShield)target);                              // Chance for a penalty to fc
                }
                if (target is BaseWeapon)
                {
                    SpellCraft.ApplyAttribute(from, cs.Book, cs.Id, (BaseWeapon)target, AosAttribute.SpellChanneling, m_Minimum, m_Maximum);
                    SpellCraft.AdjustFastCast((BaseWeapon)target);                              // Chance for a penalty to fc
                }
                else
                {
                    errorMessage = SpellCraft.AssembleMessage(SpellCraft.MsgNums.Shields, SpellCraft.MsgNums.AndWeapons);
                }
            }
            catch (SpellCraftException e)
            {
                errorMessage = e.ToString();
            }
            finally
            {
                if (null != errorMessage)
                {
                    from.SendMessage(errorMessage);
                }
            }
        }
Exemplo n.º 6
0
 public static void SerializeState(CraftState state, string filePath)
 {
     IFormatter formatter = new BinaryFormatter();
     Stream stream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None);
     formatter.Serialize(stream, state);
     stream.Close();
 }
Exemplo n.º 7
0
        public static void Callback(Mobile from, object target, object craftState)
        {
            string     errorMessage = null;
            CraftState cs           = craftState as CraftState;

            try
            {
                if (target is BaseWeapon)
                {
                    SpellCraft.ApplyAttribute(from, cs.Book, cs.Id, (BaseWeapon)target, AosAttribute.WeaponDamage, m_Minimum, m_Maximum);
                }

                else if (target is BaseJewel)
                {
                    SpellCraft.ApplyAttribute(from, cs.Book, cs.Id, (BaseJewel)target, AosAttribute.WeaponDamage, m_Minimum, m_Maximum);
                }

                else
                {
                    errorMessage = SpellCraft.AssembleMessage(SpellCraft.MsgNums.ArmorComma, SpellCraft.MsgNums.HatsComma, SpellCraft.MsgNums.AndJewelry);
                }
            }
            catch (SpellCraftException e)
            {
                errorMessage = e.ToString();
            }
            finally
            {
                if (null != errorMessage)
                {
                    from.SendMessage(errorMessage);
                }
            }
        }
Exemplo n.º 8
0
    public void SaveCraft(string newFilePath = null)
    {
        var textureManager = TextureBrowser.GetFirstInstance();

        if (newFilePath != null)
        {
            FilePath = newFilePath;
        }
        var craft = new CraftState()
        {
            CraftScale        = transform.localScale.x,
            RootPositionX     = transform.position.x,
            RootPositionY     = transform.position.y,
            RootPositionZ     = transform.position.z,
            RootColor         = ColorHexConverter.RGB_To_Hex(renderer.material.color),
            RootTexture       = textureManager.GetTextureIndex(renderer.material.mainTexture),
            ChildrenLocalPosX = new float[transform.childCount],
            ChildrenLocalPosY = new float[transform.childCount],
            ChildrenLocalPosZ = new float[transform.childCount],
            ChildrenColors    = new string[transform.childCount],
            ChildrensTextures = new int[transform.childCount]
        };

        for (int i = 0; i < transform.childCount; i++)
        {
            var child = transform.GetChild(i);
            craft.ChildrenLocalPosX[i] = child.localPosition.x;
            craft.ChildrenLocalPosY[i] = child.localPosition.y;
            craft.ChildrenLocalPosZ[i] = child.localPosition.z;
            craft.ChildrenColors[i]    = ColorHexConverter.RGB_To_Hex(child.renderer.material.color);
            craft.ChildrensTextures[i] = textureManager.GetTextureIndex(child.renderer.material.mainTexture);
        }
        CraftState.SerializeState(craft, FilePath);
    }
Exemplo n.º 9
0
    public bool LoadCraft(string newFilePath)
    {
        var textureManager = TextureBrowser.GetFirstInstance();

        if (newFilePath != FilePath)
        {
            FilePath = newFilePath;
        }
        Debug.Log(FilePath);
        CraftState craft = null;

        try
        {
            craft = CraftState.DeserializeState(FilePath);
        }
        catch
        {
            notification.ShowNotification("Unable to load the geometry. \nThe file might be corrupted.");
            return(false);
        }
        for (int i = 0; i < transform.childCount; i++)
        {
            Destroy(transform.GetChild(i).gameObject);
        }
        transform.localScale    = new Vector3(craft.CraftScale, craft.CraftScale, craft.CraftScale);
        renderer.material.color = ColorHexConverter.HexToRGB(craft.RootColor);
        if (craft.RootTexture == 0)
        {
            renderer.material.mainTexture = null;
        }
        else
        {
            renderer.material.mainTexture = textureManager.GetTextureByIndex(craft.RootTexture);
        }
        AddSpawnEffect(gameObject);
        for (int i = 0; i < craft.ChildrenColors.Length; i++)
        {
            var child = Instantiate(Resources.Load(childCubePrefabName), transform.position, transform.rotation) as GameObject;
            child.renderer.material       = new Material(sourceMaterial);
            child.transform.parent        = transform;
            child.transform.localScale    = new Vector3(1, 1, 1);
            child.transform.localPosition = new Vector3(craft.ChildrenLocalPosX[i], craft.ChildrenLocalPosY[i], craft.ChildrenLocalPosZ[i]);
            child.renderer.material.color = ColorHexConverter.HexToRGB(craft.ChildrenColors[i]);
            if (craft.ChildrensTextures[i] == 0)
            {
                child.renderer.material.mainTexture = null;
            }
            else
            {
                child.renderer.material.mainTexture = textureManager.GetTextureByIndex(craft.ChildrensTextures[i]);
            }
            AddSpawnEffect(child);
        }
        return(true);
    }
Exemplo n.º 10
0
 public static CraftState DeserializeState(string filePath)
 {
     try
     {
         IFormatter formatter = new BinaryFormatter();
         Stream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
         CraftState craft = (CraftState)formatter.Deserialize(stream);
         stream.Close();
         return craft;
     }
     catch (SerializationException se)
     {
         throw se;
     }
 }
Exemplo n.º 11
0
        public static void Callback(Mobile from, object target, object craftState)
        {
            string     errorMessage = null;
            CraftState cs           = craftState as CraftState;

            try
            {
                if (target is BaseArmor)
                {
                    SpellCraft.ApplyResistance(from, cs.Book, cs.Id, (BaseArmor)target, ResistanceType.Physical, m_Minimum, m_Maximum);
                }

                else if (target is BaseWeapon)
                {
                    SpellCraft.ApplyAttribute(from, cs.Book, cs.Id, (BaseWeapon)target, AosWeaponAttribute.ResistPhysicalBonus, m_Minimum, m_Maximum);
                }

                else if (target is BaseHat)
                {
                    SpellCraft.ApplyAttribute(from, cs.Book, cs.Id, (BaseHat)target, AosElementAttribute.Physical, m_Minimum, m_Maximum);
                }

                else if (target is BaseJewel)
                {
                    SpellCraft.ApplyAttribute(from, cs.Book, cs.Id, (BaseJewel)target, AosElementAttribute.Physical, m_Minimum, m_Maximum);
                }

                else
                {
                    errorMessage = SpellCraft.AssembleMessage(SpellCraft.MsgNums.ArmorComma, SpellCraft.MsgNums.ShieldsComma, SpellCraft.MsgNums.WeaponsComma, SpellCraft.MsgNums.HatsComma, SpellCraft.MsgNums.AndJewelry);
                }
            }
            catch (SpellCraftException e)
            {
                errorMessage = e.ToString();
            }
            finally
            {
                if (null != errorMessage)
                {
                    from.SendMessage(errorMessage);
                }
            }
        }
Exemplo n.º 12
0
        public override void Tick()
        {
            base.Tick();
            if (curState == CraftState.Crafting && this.TryGetComp <CompPowerTrader>().PowerOn)
            {
                if (this.TryGetComp <CompRefuelable>().Fuel >= fuelCost)
                {
                    ticks++;
                    if (ticks % 120 == 0)
                    {
                        FleckMaker.ThrowMicroSparks(Position.ToVector3(), Map);
                        //SoundDefOf.FloatMenu_Open.PlayOneShot(this);
                    }

                    if (ticks >= oneDayTicks)
                    {
                        curState = CraftState.Done;
                    }
                }
            }

            if (curState != CraftState.Done)
            {
                return;
            }

            ticks = 0;
            var pawn   = WarframeStaticMethods.GetWarframePawn(nowCraftKind);
            var loc    = CellFinder.RandomClosewalkCellNear(Position, Map, 2);
            var unused = (Pawn)GenSpawn.Spawn(pawn, loc, Map);

            SoundDefOf.TinyBell.PlayOneShotOnCamera();
            this.TryGetComp <CompRefuelable>().ConsumeFuel(fuelCost);
            nowCraftKind = null;
            curState     = CraftState.Stop;
            Head         = null;
            Body         = null;
            Inside       = null;
        }
Exemplo n.º 13
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (var gz in base.GetGizmos())
            {
                yield return(gz);
            }

            if (DebugSettings.godMode && curState == CraftState.Crafting)
            {
                yield return(new Command_Action
                {
                    defaultLabel = "Debug:Finish",
                    action = delegate { curState = CraftState.Done; }
                });
            }

            yield return(new Command_Action
            {
                defaultLabel = "openWFCWindow".Translate(),
                icon = TexCommand.ForbidOff,
                action = delegate { Find.WindowStack.Add(new Window_CraftWarframe(this)); }
            });
        }