Exemplo n.º 1
0
            public void OptRigidbody(string key, Atom a, ref Rigidbody v)
            {
                if (a == null)
                {
                    return;
                }

                if (!HasKey(key))
                {
                    return;
                }

                var name = c_[key].Value;
                var rb   = Utilities.FindRigidbody(a, name);

                if (rb == null)
                {
                    Synergy.LogError(
                        "receiver '" + name + "' not " +
                        "found in atom '" + a.uid + "'");

                    return;
                }

                v = rb;
            }
Exemplo n.º 2
0
            public void Opt <T>(string key, ref List <T> list)
                where T : IJsonable, new()
            {
                if (!HasKey(key))
                {
                    return;
                }

                var array = c_[key] as JSONArray;

                if (array == null)
                {
                    Synergy.LogError("key '" + key + "' is not an array");
                    return;
                }

                list.Clear();

                foreach (JSONNode n in array)
                {
                    var v = new T();

                    if (v.FromJSON(Node.Wrap(n)))
                    {
                        list.Add(v);
                    }
                }
            }
Exemplo n.º 3
0
    public SynergyObject(Synergy syn, Transform WidgetTransform, SynergyWidget WidgetScript)
    {
        synergy         = syn;
        widgetTransform = WidgetTransform;
        widgetScript    = WidgetScript;

        uniqueActiveUnits  = 0;
        uniqueTotalUnits   = 0;
        benchManagerScript = BenchManager.Instance;
    }
        public void UnprotectedDatabase()
        {
            const string   status  = @"
Warning: CM Synergy startup failed.
";
            Synergy        synergy = (Synergy)NetReflector.Read(SynergyMother.ConfigValues);
            SynergyCommand command = new SynergyCommand(synergy.Connection, synergy.Project);

            Assert.IsFalse(command.IsDatabaseProtected(status, synergy.Connection.Host, synergy.Connection.Database));
        }
        public void ProtectedDatabase()
        {
            const string   status  = @"
Warning: Database \\myserver\share\mydatabase on host myserver is protected.  Starting a session is not allowed.
Warning: CM Synergy startup failed.
";
            Synergy        synergy = (Synergy)NetReflector.Read(SynergyMother.ConfigValues);
            SynergyCommand command = new SynergyCommand(synergy.Connection, synergy.Project);

            Assert.IsTrue(command.IsDatabaseProtected(status, synergy.Connection.Host, synergy.Connection.Database));
        }
Exemplo n.º 6
0
            public void Save(string path)
            {
                var n = node_ as JSONClass;

                if (n == null)
                {
                    Synergy.LogError("can't save, empty");
                    return;
                }

                SuperController.singleton.SaveJSON(n, path);
            }
        public virtual void SetUp()
        {
            /* TODO We should test use of custom environmental variables.
             *      .NET 2.0 adds the method Environment.SetEnvironmentVariable(),
             *      which would support this approach */

            synergy = (Synergy)NetReflector.Read(SynergyMother.ConfigValues);
            Assert.IsNotNull(synergy.UrlBuilder);
            Assert.IsTrue(synergy.UrlBuilder is ChangeSynergyUrlBuilder);
            synergyUrlBuilder = synergy.UrlBuilder as ChangeSynergyUrlBuilder;
            Assert.IsNotNull(synergyUrlBuilder);
        }
        public void GetReconfigureTimeShouldHandleNonUSDates()
        {
            string dateString  = "samedi 2 décembre 2006";
            IMock  mockCommand = new DynamicMock(typeof(ISynergyCommand));

            mockCommand.ExpectAndReturn("Execute", ProcessResultFixture.CreateSuccessfulResult(dateString), new IsAnything());
            SynergyConnectionInfo connectionInfo = new SynergyConnectionInfo();

            connectionInfo.FormatProvider = new CultureInfo("FR-fr");
            Synergy  synergy = new Synergy(connectionInfo, new SynergyProjectInfo(), (ISynergyCommand)mockCommand.MockInstance, null);
            DateTime time    = synergy.GetReconfigureTime();

            mockCommand.Verify();
        }
Exemplo n.º 9
0
            public string AsString(string what = "")
            {
                if (node_ == null || (string.IsNullOrEmpty(node_.Value)))
                {
                    if (what != "")
                    {
                        Synergy.LogError(what + " is not a string");
                    }

                    return(null);
                }

                return(node_.Value);
            }
        public void GetReconfigureTimeShouldHandleNonUSDates()
        {
            string dateString  = "samedi 2 décembre 2006";
            var    mockCommand = new Mock <ISynergyCommand>();

            mockCommand.Setup(command => command.Execute(It.IsAny <ProcessInfo>())).Returns(ProcessResultFixture.CreateSuccessfulResult(dateString)).Verifiable();
            SynergyConnectionInfo connectionInfo = new SynergyConnectionInfo();

            connectionInfo.FormatProvider = new CultureInfo("FR-fr");
            Synergy  synergy = new Synergy(connectionInfo, new SynergyProjectInfo(), (ISynergyCommand)mockCommand.Object, null);
            DateTime time    = synergy.GetReconfigureTime();

            mockCommand.Verify();
        }
Exemplo n.º 11
0
    public bool ThrowShield(Synergy synergy)
    {
        bool cooldownFinished = Time.time - lastThrowTime >= cooldownTime;

        if (cooldownFinished && synergy.Consume(synergyCost))
        {
            GameObject projectile = Instantiate(projectilePrefab, aimingTransform.position, Quaternion.Euler(0, 0, 0));
            projectile.GetComponent <StationaryShieldProjectile>().stationaryShieldPower = this;
            projectile.GetComponent <Rigidbody>().AddForce(aimingTransform.forward.normalized * shootForce);
            lastThrowTime = Time.time;
            return(true);
        }
        return(false);
    }
Exemplo n.º 12
0
            public Object AsObject(string what = "")
            {
                var o = node_ as JSONClass;

                if (o == null)
                {
                    if (what != "")
                    {
                        Synergy.LogError(what + " is not an object");
                    }

                    return(null);
                }

                return(Object.Wrap(o));
            }
Exemplo n.º 13
0
            public Array AsArray(string what = "")
            {
                var a = node_ as JSONArray;

                if (a == null)
                {
                    if (what != "")
                    {
                        Synergy.LogError(what + " is not an array");
                    }

                    return(null);
                }

                return(Array.Wrap(a));
            }
Exemplo n.º 14
0
        public IActionResult like(int UserId, int PostId)
        {
            Synergy JoinFan = new Synergy();

            JoinFan.UserId   = UserId;
            JoinFan.PostId   = PostId;
            ViewBag.ThisPost = dbContext.Posts.Include(g => g.Likers).FirstOrDefault(c => c.PostId == PostId);
            ViewBag.ThisUser = dbContext.Users.Include(l => l.Synergies).FirstOrDefault(c => c.UserId == UserId);
            var ThisPost = ViewBag.ThisPost;
            var ThisUser = ViewBag.ThisUser;

            ThisUser.LikeCounter = +1;
            dbContext.Add(JoinFan);
            dbContext.SaveChanges();
            return(RedirectToAction("LikeCenter"));
        }
Exemplo n.º 15
0
        public void GetModifications()
        {
            IMock mockCommand = new DynamicMock(typeof(ISynergyCommand));

            mockCommand.ExpectAndReturn("Execute", ProcessResultFixture.CreateSuccessfulResult("output"), new IsAnything());
            mockCommand.ExpectAndReturn("Execute", ProcessResultFixture.CreateSuccessfulResult("output"), new IsAnything(), false);
            mockCommand.ExpectAndReturn("Execute", ProcessResultFixture.CreateSuccessfulResult("output"), new IsAnything(), false);
            mockCommand.ExpectAndReturn("Execute", ProcessResultFixture.CreateSuccessfulResult("output"), new IsAnything(), false);
            IMock mockParser = new DynamicMock(typeof(SynergyParser));

            mockParser.ExpectAndReturn("Parse", new Modification[0], new IsAnything(), new IsAnything(), new NotNull());

            Synergy synergy = new Synergy(new SynergyConnectionInfo(), new SynergyProjectInfo(), (ISynergyCommand)mockCommand.MockInstance, (SynergyParser)mockParser.MockInstance);

            synergy.GetModifications(new IntegrationResult(), new IntegrationResult());
            mockCommand.Verify();
        }
        public void GetModifications()
        {
            var          mockCommand = new Mock <ISynergyCommand>();
            MockSequence sequence    = new MockSequence();

            mockCommand.InSequence(sequence).Setup(command => command.Execute(It.IsAny <ProcessInfo>())).Returns(ProcessResultFixture.CreateSuccessfulResult("output")).Verifiable();
            mockCommand.InSequence(sequence).Setup(command => command.Execute(It.IsAny <ProcessInfo>(), false)).Returns(ProcessResultFixture.CreateSuccessfulResult("output")).Verifiable();
            mockCommand.InSequence(sequence).Setup(command => command.Execute(It.IsAny <ProcessInfo>(), false)).Returns(ProcessResultFixture.CreateSuccessfulResult("output")).Verifiable();
            mockCommand.InSequence(sequence).Setup(command => command.Execute(It.IsAny <ProcessInfo>(), false)).Returns(ProcessResultFixture.CreateSuccessfulResult("output")).Verifiable();
            var mockParser = new Mock <SynergyParser>();

            mockParser.Setup(parser => parser.Parse(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTime>())).Returns(new Modification[0]).Verifiable();

            Synergy synergy = new Synergy(new SynergyConnectionInfo(), new SynergyProjectInfo(), (ISynergyCommand)mockCommand.Object, (SynergyParser)mockParser.Object);

            synergy.GetModifications(new IntegrationResult(), new IntegrationResult());
            mockCommand.Verify();
        }
Exemplo n.º 17
0
    public AffectedSynergy(Synergy synergy, UnitData data)
    {
        this.synergy = synergy;

        this.affectedUnits.Add(data.unit);

        this.affectedUnitStats.Add(data.unitStats);

        uniqueUnitsPerBuff = (int)(synergy.totalSynergySize / synergy.totalBuffSize);

        uniqueUnits = 1;

        buffCounter = 0;

        if (uniqueUnits % uniqueUnitsPerBuff == 0 && buffCounter <= synergy.totalBuffSize)
        {
            AddBuff(buffCounter);
        }
    }
Exemplo n.º 18
0
            public void Add(string key, IFactoryObject v)
            {
                if (v == null || c_ == null)
                {
                    return;
                }

                var o = v.ToJSON().AsObject();

                if (o == null)
                {
                    Synergy.LogError(
                        "Factory object ToJson() did not return an object");

                    return;
                }

                o.Add("factoryTypeName", v.GetFactoryTypeName());

                c_.Add(key, o.Impl);
            }
Exemplo n.º 19
0
        public void VerifyDefaultValues()
        {
            Synergy synergy = new Synergy();

            Assert.AreEqual("ccm.exe", synergy.Connection.Executable, "#A1");
            Assert.AreEqual("localhost", synergy.Connection.Host, "#A2");
            Assert.IsNull(synergy.Connection.Database, "#A3");
            Assert.IsNull(synergy.Connection.SessionId, "#A4");
            Assert.AreEqual(3600, synergy.Connection.Timeout, "#A5");
            Assert.AreEqual('-', synergy.Connection.Delimiter, "#A6");
            Assert.IsNull(synergy.Project.Release, "#A7");
            Assert.AreEqual(0, synergy.Project.TaskFolder, "#A8");
            Assert.AreEqual(Environment.ExpandEnvironmentVariables("%USERNAME%"), synergy.Connection.Username, "#A9");
            Assert.AreEqual(String.Empty, synergy.Connection.Password, "#A10");
            Assert.AreEqual("build_mgr", synergy.Connection.Role, "#A11");
            Assert.IsFalse(synergy.Connection.PollingEnabled, "#A12");
            Assert.IsFalse(synergy.Project.BaseliningEnabled, "#A13");
            Assert.IsFalse(synergy.Project.TemplateEnabled, "#A14");
            Assert.IsNull(synergy.Project.ReconcilePaths, "#A15");
            Assert.AreEqual("Integration Testing", synergy.Project.Purpose, "#A16");
        }
Exemplo n.º 20
0
            public void Opt(string key, ref List <string> list)
            {
                if (!HasKey(key))
                {
                    return;
                }

                var array = c_[key] as JSONArray;

                if (array == null)
                {
                    Synergy.LogError("key '" + key + "' is not an array");
                    return;
                }

                list.Clear();

                foreach (JSONNode n in array)
                {
                    list.Add(n.Value);
                }
            }
        public void TestFixtureSetUp()
        {
            Synergy synergy = (Synergy)NetReflector.Read(SynergyMother.ConfigValues);

            connection                         = synergy.Connection;
            connection.Host                    = "localhost";
            connection.Username                = "******";
            connection.Password                = "******";
            connection.Role                    = "build_mgr";
            connection.Database                = @"\\server\share\dbname";
            connection.Delimiter               = '-';
            connection.WorkingDirectory        = @"C:\Program Files\Telelogic\CM Synergy 6.3\bin";
            connection.HomeDirectory           = @"C:\cmsynergy\jdoe";
            connection.ClientDatabaseDirectory = @"C:\cmsynergy\uidb";
            connection.SessionId               = "LOCALHOST:1234:127.0.0.1";
            project = synergy.Project;
            project.ProjectSpecification = "MyProject-MyProject_Int";
            project.ObjectName           = "MyProject-MyProject_Int:project:1";
            project.Purpose    = "Integration Testing";
            project.Release    = "MyProduct/1.0";
            project.TaskFolder = 1234;
        }
Exemplo n.º 22
0
        public void ApplyLabel()
        {
            IMock mockCommand = new DynamicMock(typeof(ISynergyCommand));

            mockCommand.ExpectAndReturn("Execute", ProcessResultFixture.CreateSuccessfulResult(DateTime.MinValue.ToString(CultureInfo.InvariantCulture)), new IsAnything());
            mockCommand.ExpectAndReturn("Execute", ProcessResultFixture.CreateSuccessfulResult("output"), new IsAnything());
            mockCommand.ExpectAndReturn("Execute", ProcessResultFixture.CreateSuccessfulResult("output"), new IsAnything(), false);
            mockCommand.ExpectAndReturn("Execute", ProcessResultFixture.CreateSuccessfulResult("output"), new IsAnything(), false);
            mockCommand.ExpectAndReturn("Execute", ProcessResultFixture.CreateSuccessfulResult("output"), new IsAnything(), false);
            IMock mockParser = new DynamicMock(typeof(SynergyParser));

            mockParser.ExpectAndReturn("Parse", new Modification[0], new IsAnything(), new IsAnything(), new NotNull());

            SynergyConnectionInfo connectionInfo = new SynergyConnectionInfo();

            connectionInfo.FormatProvider = CultureInfo.InvariantCulture;
            Synergy           synergy           = new Synergy(connectionInfo, new SynergyProjectInfo(), (ISynergyCommand)mockCommand.MockInstance, (SynergyParser)mockParser.MockInstance);
            IntegrationResult integrationResult = new IntegrationResult();

            integrationResult.Status = ThoughtWorks.CruiseControl.Remote.IntegrationStatus.Success;
            synergy.LabelSourceControl(integrationResult);
            mockCommand.Verify();
        }
        public void ApplyLabel()
        {
            var          mockCommand = new Mock <ISynergyCommand>();
            MockSequence sequence    = new MockSequence();

            mockCommand.InSequence(sequence).Setup(command => command.Execute(It.IsAny <ProcessInfo>())).Returns(ProcessResultFixture.CreateSuccessfulResult(DateTime.MinValue.ToString(CultureInfo.InvariantCulture))).Verifiable();
            mockCommand.InSequence(sequence).Setup(command => command.Execute(It.IsAny <ProcessInfo>())).Returns(ProcessResultFixture.CreateSuccessfulResult("output")).Verifiable();
            mockCommand.InSequence(sequence).Setup(command => command.Execute(It.IsAny <ProcessInfo>(), false)).Returns(ProcessResultFixture.CreateSuccessfulResult("output")).Verifiable();
            mockCommand.InSequence(sequence).Setup(command => command.Execute(It.IsAny <ProcessInfo>(), false)).Returns(ProcessResultFixture.CreateSuccessfulResult("output")).Verifiable();
            mockCommand.InSequence(sequence).Setup(command => command.Execute(It.IsAny <ProcessInfo>(), false)).Returns(ProcessResultFixture.CreateSuccessfulResult("output")).Verifiable();
            var mockParser = new Mock <SynergyParser>();

            mockParser.Setup(parser => parser.Parse(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTime>())).Returns(new Modification[0]).Verifiable();

            SynergyConnectionInfo connectionInfo = new SynergyConnectionInfo();

            connectionInfo.FormatProvider = CultureInfo.InvariantCulture;
            Synergy           synergy           = new Synergy(connectionInfo, new SynergyProjectInfo(), (ISynergyCommand)mockCommand.Object, (SynergyParser)mockParser.Object);
            IntegrationResult integrationResult = new IntegrationResult();

            integrationResult.Status = ThoughtWorks.CruiseControl.Remote.IntegrationStatus.Success;
            synergy.LabelSourceControl(integrationResult);
            mockCommand.Verify();
        }
Exemplo n.º 24
0
        public void PopulateFromConfigurationXml()
        {
            Synergy synergy = (Synergy)NetReflector.Read(SynergyMother.ConfigValues);

            Assert.AreEqual("ccm.cmd", synergy.Connection.Executable);
            Assert.AreEqual("myserver", synergy.Connection.Host);
            Assert.AreEqual(@"\\myserver\share\mydatabase", synergy.Connection.Database);
            Assert.AreEqual(600, synergy.Connection.Timeout);
            Assert.AreEqual("Product/1.0", synergy.Project.Release);
            Assert.AreEqual(1234, synergy.Project.TaskFolder);
            Assert.AreEqual("jdoe", synergy.Connection.Username);
            Assert.AreEqual("password", synergy.Connection.Password);
            Assert.AreEqual("developer", synergy.Connection.Role);
            Assert.IsTrue(synergy.Connection.PollingEnabled);
            Assert.IsTrue(synergy.Project.BaseliningEnabled);
            Assert.IsTrue(synergy.Project.TemplateEnabled);
            Assert.IsNotNull(synergy.Project.ReconcilePaths);
            Assert.AreEqual(2, synergy.Project.ReconcilePaths.Length);
            Assert.AreEqual(@"Product\bin", synergy.Project.ReconcilePaths[0]);
            Assert.AreEqual(@"Product\temp.txt", synergy.Project.ReconcilePaths[1]);
            Assert.AreEqual("Custom Purpose", synergy.Project.Purpose);
            Assert.AreEqual(@"D:\cmsynergy\jdoe", synergy.Connection.HomeDirectory);
            Assert.AreEqual(@"D:\cmsynergy\uidb", synergy.Connection.ClientDatabaseDirectory);
        }
Exemplo n.º 25
0
        private void UpdateTiles(PlayerType mapType)
        {
            var map = GameModel.Instance.GetMap(mapType);

            var listConsoCells     = new List <Position>();
            var listConsoThoughts  = new List <Position>();
            var listConsoNutrients = new List <Position>();
            var listConsoIdeas     = new List <Position>();

            //execution fonctions
            for (int j = 0; j < map.GetTiles().GetLength(1); j++)
            {
                for (int i = 0; i < map.GetTiles().GetLength(0); i++)
                {
                    var tmppos = new Position(i, j);
                    if (tmppos.IsInMap(map.GetTiles().GetLength(1)))
                    {
                        FunctionInfo fonctions = TileItemFunctionInfo.Get(map.GetTiles()[i, j].Item.ItemType);
                        fonctions.MainFunction.Execute(mapType, tmppos);
                        fonctions.SecondaryFunction.Execute(mapType, tmppos);

                        if (TileItemInfo.Get(map.GetTiles()[i, j].Item.ItemType).MaintenanceCellCostRate > 0)
                        {
                            listConsoCells.Add(tmppos);
                        }
                        if (TileItemInfo.Get(map.GetTiles()[i, j].Item.ItemType).MaintenanceThoughtCostRate > 0)
                        {
                            listConsoThoughts.Add(tmppos);
                        }
                        if (TileItemInfo.Get(map.GetTiles()[i, j].Item.ItemType).MaintenanceNutrientCostRate > 0)
                        {
                            listConsoNutrients.Add(tmppos);
                        }
                        if (TileItemInfo.Get(map.GetTiles()[i, j].Item.ItemType).MaintenanceIdeaCostRate > 0)
                        {
                            listConsoIdeas.Add(tmppos);
                        }

                        //synergy
                        if (TileItemInfo.Get(map.GetTiles()[i, j].Item.ItemType).SynergyMode != TileItemSynergyMode.NONE)
                        {
                            int nbSynergy = Synergy.CheckSynergyTrigger(map, tmppos, TileItemInfo.Get(map.GetTiles()[i, j].Item.ItemType).SynergyMode, TileItemFunctionInfo.Get(map.GetTiles()[i, j].Item.ItemType).SynergyTrigger);
                            if (nbSynergy > 0)
                            {
                                fonctions.SynergyFunction.Execute(mapType, tmppos, nbSynergy);
                                map.GetTiles()[i, j].Item.Synergy = nbSynergy;
                            }
                        }

                        //maintenance
                        GameModel.Instance.Bank.Cells     -= TileItemInfo.Get(map.GetTiles()[i, j].Item.ItemType).MaintenanceCellCostRate;
                        GameModel.Instance.Bank.Thoughts  -= TileItemInfo.Get(map.GetTiles()[i, j].Item.ItemType).MaintenanceThoughtCostRate;
                        GameModel.Instance.Bank.Nutrients -= TileItemInfo.Get(map.GetTiles()[i, j].Item.ItemType).MaintenanceNutrientCostRate;
                        GameModel.Instance.Bank.Ideas     -= TileItemInfo.Get(map.GetTiles()[i, j].Item.ItemType).MaintenanceIdeaCostRate;
                    }
                }
            }

            if (GameModel.Instance.Bank.Cells < 0 && listConsoCells.Count > 0)
            {
                var removePos = listConsoCells[random.Next(listConsoCells.Count)];
                map.GetTiles()[removePos.X, removePos.Y].Item = TileItemInfo.GetClone(TileItemType.NONE);
                GameModel.Instance.Bank.Cells = 0;
            }
            if (GameModel.Instance.Bank.Thoughts < 0 && listConsoThoughts.Count > 0)
            {
                var removePos = listConsoThoughts[random.Next(listConsoThoughts.Count)];
                map.GetTiles()[removePos.X, removePos.Y].Item = TileItemInfo.GetClone(TileItemType.NONE);
                GameModel.Instance.Bank.Thoughts = 0;
            }
            if (GameModel.Instance.Bank.Nutrients < 0 && listConsoNutrients.Count > 0)
            {
                var removePos = listConsoNutrients[random.Next(listConsoNutrients.Count)];
                map.GetTiles()[removePos.X, removePos.Y].Item = TileItemInfo.GetClone(TileItemType.NONE);
                GameModel.Instance.Bank.Nutrients             = 0;
            }
            if (GameModel.Instance.Bank.Ideas < 0 && listConsoIdeas.Count > 0)
            {
                var removePos = listConsoIdeas[random.Next(listConsoIdeas.Count)];
                map.GetTiles()[removePos.X, removePos.Y].Item = TileItemInfo.GetClone(TileItemType.NONE);
                GameModel.Instance.Bank.Ideas = 0;
            }
        }
Exemplo n.º 26
0
    /**
     *
     */
    internal static WeaponStats RandomStats(int level)
    {
        int dps = level;
        int gold;

        switch (level)
        {
        case 1:
            gold = 50;
            break;

        case 2:
            gold = 100;
            break;

        case 3:
            gold = 200;
            break;

        case 4:
            gold = 300;
            break;

        case 5:
            gold = 400;
            break;

        default:
            throw new Exception();
        }

        WeaponType weaponType;
        string     attack;
        int        time;
        int        damage;

        switch (UnityEngine.Random.Range(0, 6))
        {
        case 0:
            weaponType = WeaponType.Sword;
            attack     = "Slash";
            time       = UnityEngine.Random.Range(2, 5);
            damage     = dps * time;
            break;

        case 1:
            weaponType = WeaponType.Whip;
            attack     = "Crack";
            time       = UnityEngine.Random.Range(2, 4);
            damage     = dps * time;
            break;

        case 2:
            weaponType = WeaponType.Staff;
            attack     = "Bonk";
            time       = UnityEngine.Random.Range(3, 6);
            damage     = dps * time;
            break;

        case 3:
            weaponType = WeaponType.Hammer;
            attack     = "Bang";
            time       = UnityEngine.Random.Range(4, 6);
            damage     = dps * time;
            break;

        case 4:
            weaponType = WeaponType.Bow;
            attack     = "Woosh";
            time       = UnityEngine.Random.Range(3, 5);
            damage     = dps * time;
            break;

        case 5:
            weaponType = WeaponType.Dagger;
            attack     = "Stab";
            time       = UnityEngine.Random.Range(1, 3);
            damage     = dps * time;
            break;

        default:
            throw new System.Exception();
        }

        Color   weaponColor;
        Synergy synergy;

        switch (UnityEngine.Random.Range(0, 3))
        {
        case 0:
            weaponColor = Color.red;
            synergy     = (Synergy)UnityEngine.Random.Range(0, 2);
            break;

        case 1:
            weaponColor = Color.blue;
            synergy     = (Synergy)UnityEngine.Random.Range(2, 4);
            break;

        case 2:
            weaponColor = Color.green;
            synergy     = (Synergy)UnityEngine.Random.Range(4, 6);
            break;

        default:
            throw new System.Exception();
        }

        string weaponName
            = adjectives[UnityEngine.Random.Range(0, 10)] + " " + weaponType.ToString() + " of " + nouns[UnityEngine.Random.Range(0, 10)];

        return(new WeaponStats()
        {
            attackName = attack,
            type = weaponType,
            dmg = damage,
            cooldown = time,
            color = weaponColor,
            sprite = Resources.Load <Sprite>("Sprites/" + weaponType.ToString()),
            name = weaponName,
            synergy = synergy,
            level = level,
            price = gold,
            fromVendor = false,
        });
    }
Exemplo n.º 27
0
            public void OptFactoryObjects <Factory, T>(string key, ref List <T> list)
                where Factory : IFactory <T>, new()
                where T : IFactoryObject
            {
                if (!HasKey(key))
                {
                    return;
                }

                var node = c_[key];

                if (node == null)
                {
                    return;
                }

                var array = node as JSONArray;

                if (array == null)
                {
                    Synergy.LogError("key '" + key + "' is not an array");
                    return;
                }

                list.Clear();

                int i = 0;

                foreach (JSONNode n in array)
                {
                    var o = n as JSONClass;
                    if (o == null)
                    {
                        Synergy.LogError(
                            "array element " + i.ToString() + " in key " +
                            key + " is not an object");

                        continue;
                    }

                    if (!o.HasKey("factoryTypeName"))
                    {
                        continue;
                    }

                    var typeName = o["factoryTypeName"].Value;

                    var temp = new Factory().Create(typeName);
                    if (temp == null)
                    {
                        continue;
                    }

                    if (!temp.FromJSON(Object.Wrap(o)))
                    {
                        continue;
                    }

                    list.Add(temp);
                }
            }
Exemplo n.º 28
0
        protected string SetFactor(int rowRegExpID, int colRegExpID, string value)
        {
            if (!String.IsNullOrEmpty(value))
            {
                double factor;
                if (TryParseDouble(value, out factor))
                {
                    var isZero = factor.Equals(_defaultValue);
                    if (!isZero)
                    {
                        if (factor < _min)
                        {
                            factor = _min;
                        }

                        if (factor > _max)
                        {
                            factor = _max;
                        }
                    }

                    value = factor.ToString(_factorFormat);

                    ///////////////////////////////////////////////////////////////////////////////

                    var exists        = false;
                    var regExpSynergy = _viewData.RegExpSynergies.FirstOrDefault(x => x.RegExpID == rowRegExpID);
                    if (regExpSynergy == null)
                    {
                        if (isZero)
                        {
                            CleanupRegExpSynergies();
                            return(value);
                        }

                        regExpSynergy = new RegExpSynergy
                        {
                            RegExpID = rowRegExpID
                        };
                    }
                    else
                    {
                        exists = true;
                    }

                    ///////////////////////////////////////////////////////////////////////////////

                    var matchingSynergy = regExpSynergy.Synergies.FirstOrDefault(x => x.MatchingRegExpId == colRegExpID);
                    if (matchingSynergy == null)
                    {
                        if (isZero)
                        {
                            CleanupRegExpSynergies();
                            return(value);
                        }

                        matchingSynergy = new Synergy
                        {
                            MatchingRegExpId = colRegExpID
                        };

                        regExpSynergy.Synergies.Add(matchingSynergy);
                    }
                    else
                    {
                        if (isZero)
                        {
                            regExpSynergy.Synergies.Remove(matchingSynergy);
                            CleanupRegExpSynergies();
                            return(value);
                        }
                    }

                    ///////////////////////////////////////////////////////////////////////////////

                    matchingSynergy.Factor = factor;

                    if (!exists)
                    {
                        _viewData.RegExpSynergies.Add(regExpSynergy);
                    }
                }
            }
            else
            {
                value = _defaultValue.ToString(_factorFormat);
            }

            return(value);
        }