Example #1
0
 void Awake()
 {
     if (instance == null)
         instance = this;
     else if (instance != this)
         Destroy(gameObject);
 }
Example #2
0
 //: base(types, filter)
 /// <summary>
 /// Initializes all the components of the explorer.
 /// </summary>
 /// <param name="userParams"></param>
 public RandomExplorer(Collection<Type> types, IReflectionFilter filter, bool exceptionLearning,
     int randomSeed, int arrayMaxSize, StatsManager stats, ActionSet actions)
 {
     this.actions = actions;
     this.filter = filter;
     this.arrayMaxSize = arrayMaxSize;
     this.stats = stats;
 }
	public static void Initialize() {
		LevelManager = new LevelManager();
		PlayerManager = new PlayerManager();
		EnemyManager = new EnemyManager();
 		ResourceCache = (new GameObject()).AddComponent<ResourceCache>();
		EntityTemplateManager = new EntityTemplateManager();
		SoundManager = new SoundManager();
		StatsManager = new StatsManager();
	}
Example #4
0
 void Awake()
 {
     // Don't destroy object on load
     if (stats == null) {
         DontDestroyOnLoad (gameObject); //this gameobject will persist from scene to scene
         stats = this;
     } else if (stats != this) {
         Destroy (gameObject);
     }
     Load (); //Muted didn't work until I put it here, needs to load variables before Mute object initiates for retrieval of said variables
 }
Example #5
0
        public Player(Client client)
            : base(client.Manager, (ushort)client.Character.ObjectType, client.Random)
        {
            this.client = client;
            statsMgr = new StatsManager(this);
            Name = client.Account.Name;
            AccountId = client.Account.AccountId;

            Level = client.Character.Level;
            Experience = client.Character.Exp;
            ExperienceGoal = GetExpGoal(client.Character.Level);
            Stars = GetStars();
            Texture1 = client.Character.Tex1;
            Texture2 = client.Character.Tex2;
            Credits = client.Account.Credits;
            NameChosen = client.Account.NameChosen;
            CurrentFame = client.Account.Stats.Fame;
            Fame = client.Character.CurrentFame;
            var state = client.Account.Stats.ClassStates.SingleOrDefault(_ => _.ObjectType == ObjectType);
            if (state != null)
                FameGoal = GetFameGoal(state.BestFame);
            else
                FameGoal = GetFameGoal(0);
            Glowing = true;
            Guild = "";
            GuildRank = -1;
            HP = client.Character.HitPoints;
            MP = client.Character.MagicPoints;
            ConditionEffects = 0;

            Inventory = new Inventory(this,
                client.Character.Equipment
                    .Select(_ => _ == 0xffff ? null : client.Manager.GameData.Items[_])
                    .ToArray());
            Inventory.InventoryChanged += (sender, e) => CalculateBoost();
            SlotTypes = Utils.FromCommaSepString32(client.Manager.GameData.ObjectTypeToElement[ObjectType].Element("SlotTypes").Value);
            Stats = new int[]
            {
                client.Character.MaxHitPoints,
                client.Character.MaxMagicPoints,
                client.Character.Attack,
                client.Character.Defense,
                client.Character.Speed,
                client.Character.HpRegen,
                client.Character.MpRegen,
                client.Character.Dexterity,
            };
        }
Example #6
0
        public Player(ClientProcessor psr)
            : base((short)psr.Character.ObjectType, psr.Random)
        {
            this.psr = psr;
            statsMgr = new StatsManager(this);
            Name = psr.Account.Name;
            AccountId = psr.Account.AccountId;

            Level = psr.Character.Level;
            Experience = psr.Character.Exp;
            ExperienceGoal = GetExpGoal(psr.Character.Level);
            Stars = GetStars();
            Texture1 = psr.Character.Tex1;
            Texture2 = psr.Character.Tex2;
            Credits = psr.Account.Credits;
            NameChosen = psr.Account.NameChosen;
            CurrentFame = psr.Account.Stats.Fame;
            Fame = psr.Character.CurrentFame;
            var state = psr.Account.Stats.ClassStates.SingleOrDefault(_ => _.ObjectType == ObjectType);
            if (state != null)
                FameGoal = GetFameGoal(state.BestFame);
            else
                FameGoal = GetFameGoal(0);
            Glowing = true;
            Guild = psr.Account.Guild.Name;
            GuildRank = -1;
            if (psr.Account.Guild.Name != null)
            {
                GuildRank = psr.Account.Guild.Rank;
            }
            HP = psr.Character.HitPoints;
            MP = psr.Character.MagicPoints;
            ConditionEffects = 0;

            Inventory = psr.Character.Equipment.Select(_ => _ == -1 ? null : XmlDatas.ItemDescs[_]).ToArray();
            SlotTypes = Utils.FromCommaSepString32(XmlDatas.TypeToElement[ObjectType].Element("SlotTypes").Value);
            Stats = new int[]
            {
                psr.Character.MaxHitPoints,
                psr.Character.MaxMagicPoints,
                psr.Character.Attack,
                psr.Character.Defense,
                psr.Character.Speed,
                psr.Character.HpRegen,
                psr.Character.MpRegen,
                psr.Character.Dexterity,
            };
        }
Example #7
0
	// Use this for initialization
	void Start () {
		playerSpeedModifier = 0f;
		playerBulletSpeedModifier = 0f;
		playerFireRateModifier = 0f;
		playerAugment = null;
		playerPrefix = gameObject.name;

		if (playerPrefix == "P1") {
			otherPlayerPrefix = "P2";
		} else {
			otherPlayerPrefix = "P1";
		}

		otherPlayerStats = GameObject.Find (otherPlayerPrefix).GetComponent<StatsManager> ();
		playerAugSprite = GameObject.Find (playerPrefix + "Aug");
		otherPlayerAugSprite = GameObject.Find (otherPlayerPrefix + "Aug");
	}
Example #8
0
 void Start()
 {
     stats = GameObject.FindGameObjectWithTag("GameController").GetComponent <StatsManager>();
     stats.UpdateAmmo(ammo);
 }
Example #9
0
 private void Awake()
 {
     instance = this;
 }
Example #10
0
        public Player(Client client, bool saveInventory = true)
            : base(client.Manager, client.Character.ObjectType)
        {
            var settings = Manager.Resources.Settings;
            var gameData = Manager.Resources.GameData;

            _client = client;

            // found in player.update partial
            Sight           = new Sight(this);
            _clientEntities = new UpdatedSet(this);

            _accountId      = new SV <int>(this, StatsType.AccountId, client.Account.AccountId, true);
            _experience     = new SV <int>(this, StatsType.Experience, client.Character.Experience, true);
            _experienceGoal = new SV <int>(this, StatsType.ExperienceGoal, 0, true);
            _level          = new SV <int>(this, StatsType.Level, client.Character.Level);
            _currentFame    = new SV <int>(this, StatsType.CurrentFame, client.Account.Fame, true);
            _fame           = new SV <int>(this, StatsType.Fame, client.Character.Fame, true);
            _fameGoal       = new SV <int>(this, StatsType.FameGoal, 0, true);
            _stars          = new SV <int>(this, StatsType.Stars, 0);
            _guild          = new SV <string>(this, StatsType.Guild, "");
            _guildRank      = new SV <int>(this, StatsType.GuildRank, -1);
            _credits        = new SV <int>(this, StatsType.Credits, client.Account.Credits, true);
            _nameChosen     = new SV <bool>(this, StatsType.NameChosen, client.Account.NameChosen, false, v => _client.Account?.NameChosen ?? v);
            _texture1       = new SV <int>(this, StatsType.Texture1, client.Character.Tex1);
            _texture2       = new SV <int>(this, StatsType.Texture2, client.Character.Tex2);
            _skin           = new SV <int>(this, StatsType.Skin, 0);
            _glow           = new SV <int>(this, StatsType.Glow, 0);
            _mp             = new SV <int>(this, StatsType.MP, client.Character.MP);
            _hasBackpack    = new SV <bool>(this, StatsType.HasBackpack, client.Character.HasBackpack, true);
            _oxygenBar      = new SV <int>(this, StatsType.OxygenBar, -1, true);
            _rank           = new SV <int>(this, StatsType.Rank, client.Account.Rank);
            _admin          = new SV <int>(this, StatsType.Admin, client.Account.Admin ? 1 : 0);

            Name             = client.Account.Name;
            HP               = client.Character.HP;
            ConditionEffects = 0;

            var s = (ushort)client.Character.Skin;

            if (gameData.Skins.Keys.Contains(s))
            {
                SetDefaultSkin(s);
                SetDefaultSize(gameData.Skins[s].Size);
            }

            var guild = Manager.Database.GetGuild(client.Account.GuildId);

            if (guild?.Name != null)
            {
                Guild     = guild.Name;
                GuildRank = client.Account.GuildRank;
            }

            PetId = client.Character.PetId;

            HealthPots = new ItemStacker(this, 254, 0x0A22,
                                         client.Character.HealthStackCount, settings.MaxStackablePotions);
            MagicPots = new ItemStacker(this, 255, 0x0A23,
                                        client.Character.MagicStackCount, settings.MaxStackablePotions);
            Stacks = new ItemStacker[] { HealthPots, MagicPots };

            // inventory setup
            DbLink    = new DbCharInv(Client.Account, Client.Character.CharId);
            Inventory = new Inventory(this,
                                      Utils.ResizeArray(
                                          (DbLink as DbCharInv).Items
                                          .Select(_ => (_ == 0xffff || !gameData.Items.ContainsKey(_)) ? null : gameData.Items[_])
                                          .ToArray(),
                                          20));
            if (!saveInventory)
            {
                DbLink = null;
            }

            Inventory.InventoryChanged += (sender, e) => Stats.ReCalculateValues(e);
            SlotTypes = Utils.ResizeArray(
                gameData.Classes[ObjectType].SlotTypes,
                20);
            Stats = new StatsManager(this);

            Manager.Database.IsMuted(client.IP)
            .ContinueWith(t =>
            {
                Muted = !Client.Account.Admin && t.IsCompleted && t.Result;
            });

            Manager.Database.IsLegend(AccountId)
            .ContinueWith(t =>
            {
                Glow = t.Result ? 1 : -1;
            });
        }
Example #11
0
        private static void Main2(string[] args)
        {
            NLogConfigManager.CreateFileConfig();
            Logger = NLog.LogManager.GetCurrentClassLogger();

            if (args.Length != 1)
            {
                throw new InvalidUserParamsException(
                          "RandoopBare takes exactly one argument but was "
                          + "given the following arguments:"
                          + System.Environment.NewLine
                          + Util.PrintArray(args));;
            }

            // Parse XML file with generation parameters.
            string configFileName       = ConfigFileName.Parse(args[0]);
            RandoopConfiguration config = LoadConfigFile(configFileName);

            // Set the random number generator.
            if (config.randomSource == RandomSource.SystemRandom)
            {
                Logger.Debug("Randoom seed = " + config.randomseed);
                SystemRandom random = new SystemRandom();
                random.Init(config.randomseed);
                Enviroment.Random = random;
            }
            else
            {
                Util.Assert(config.randomSource == RandomSource.Crypto);
                Logger.Debug("Randoom seed = new System.Security.Cryptography.RNGCryptoServiceProvider()");
                Enviroment.Random = new CryptoRandom();
            }

            if (!Directory.Exists(config.outputdir))
            {
                throw new InvalidUserParamsException("output directory does not exist: "
                                                     + config.outputdir);
            }

            Collection <Assembly> assemblies = Misc.LoadAssemblies(config.assemblies);

            ////[email protected] for substituting MessageBox.Show() - start
            ////Instrument instrumentor = new Instrument();
            //foreach (FileName asm in config.assemblies)
            //{
            //    Instrument.MethodInstrument(asm.fileName, "System.Windows.Forms.MessageBox::Show", "System.Logger.Debug");
            //}
            ////[email protected] for substituting MessageBox.Show() - end

            IReflectionFilter filter1 = new VisibilityFilter(config);
            ConfigFilesFilter filter2 = new ConfigFilesFilter(config);

            Logger.Debug("========== REFLECTION PATTERNS:");
            filter2.PrintFilter(Console.Out);

            IReflectionFilter filter = new ComposableFilter(filter1, filter2);

            Collection <Type> typesToExplore = ReflectionUtils.GetExplorableTypes(assemblies);

            PlanManager planManager = new PlanManager(config);

            planManager.builderPlans.AddEnumConstantsToPlanDB(typesToExplore);
            planManager.builderPlans.AddConstantsToTDB(config);

            Logger.Debug("========== INITIAL PRIMITIVE VALUES:");
            planManager.builderPlans.PrintPrimitives(Console.Out);

            StatsManager stats = new StatsManager(config);

            Logger.Debug("Analyzing assembly.");

            ActionSet actions;

            try
            {
                actions = new ActionSet(typesToExplore, filter);
            }
            catch (EmpytActionSetException)
            {
                string msg = "After filtering based on configuration files, no remaining methods or constructors to explore.";
                throw new InvalidUserParamsException(msg);
            }

            Logger.Debug("Generating tests.");

            RandomExplorer explorer =
                new RandomExplorer(typesToExplore, filter, true, config.randomseed, config.arraymaxsize, stats, actions);
            ITimer t = new Timer(config.timelimit);

            try
            {
                explorer.Explore(t, planManager, config.methodweighing, config.forbidnull, true, config.fairOpt);
            }
            catch (Exception e)
            {
                Logger.Error("Explorer raised exception {0}", e.ToString());
                throw;
            }
        }
 public StatsTrackerSystem()
 {
     _statsManager = FlaiGame.Current.Services.Get<StatsManager>();
 }
Example #13
0
        public Player(RealmManager manager, Client psr)
            : base(manager, (ushort)psr.Character.ObjectType, psr.Random)
        {
            try
            {
                Client        = psr;
                Manager       = psr.Manager;
                StatsManager  = new StatsManager(this, psr.Random.CurrentSeed);
                Name          = psr.Account.Name;
                AccountId     = psr.Account.AccountId;
                FameCounter   = new FameCounter(this);
                Tokens        = psr.Account.FortuneTokens;
                HpPotionPrice = 5;
                MpPotionPrice = 5;

                Level                  = psr.Character.Level == 0 ? 1 : psr.Character.Level;
                Experience             = psr.Character.Exp;
                ExperienceGoal         = GetExpGoal(Level);
                Stars                  = GetStars();
                Texture1               = psr.Character.Tex1;
                Texture2               = psr.Character.Tex2;
                Credits                = psr.Account.Credits;
                NameChosen             = psr.Account.NameChosen;
                CurrentFame            = psr.Account.Stats.Fame;
                Fame                   = psr.Character.CurrentFame;
                XpBoosted              = psr.Character.XpBoosted;
                XpBoostTimeLeft        = psr.Character.XpTimer;
                xpFreeTimer            = XpBoostTimeLeft != -1.0;
                LootDropBoostTimeLeft  = psr.Character.LDTimer;
                lootDropBoostFreeTimer = LootDropBoost;
                LootTierBoostTimeLeft  = psr.Character.LTTimer;
                lootTierBoostFreeTimer = LootTierBoost;
                var state =
                    psr.Account.Stats.ClassStates.SingleOrDefault(_ => Utils.FromString(_.ObjectType) == ObjectType);
                FameGoal         = GetFameGoal(state?.BestFame ?? 0);
                Glowing          = IsUserInLegends();
                Guild            = GuildManager.Add(this, psr.Account.Guild);
                HP               = psr.Character.HitPoints <= 0 ? psr.Character.MaxHitPoints : psr.Character.HitPoints;
                Mp               = psr.Character.MagicPoints;
                ConditionEffects = 0;
                OxygenBar        = 100;
                HasBackpack      = psr.Character.HasBackpack == 1;
                PlayerSkin       = Client.Account.OwnedSkins.Contains(Client.Character.Skin) ? Client.Character.Skin : 0;
                HealthPotions    = psr.Character.HealthStackCount < 0 ? 0 : psr.Character.HealthStackCount;
                MagicPotions     = psr.Character.MagicStackCount < 0 ? 0 : psr.Character.MagicStackCount;

                Locked  = psr.Account.Locked ?? new List <string>();
                Ignored = psr.Account.Ignored ?? new List <string>();
                try
                {
                    Manager.Database.DoActionAsync(db =>
                    {
                        Locked     = db.GetLockeds(AccountId);
                        Ignored    = db.GetIgnoreds(AccountId);
                        Muted      = db.IsMuted(AccountId);
                        DailyQuest = psr.Account.DailyQuest;
                    });
                }
                catch (Exception ex)
                {
                    log.Error(ex);
                }

                if (Client.Account.Name == "Tidan")
                {
                    Glowing = true;
                }

                if (HasBackpack)
                {
                    var inv =
                        psr.Character.Equipment.Select(
                            _ =>
                            _ == -1
                                    ? null
                                    : (Manager.GameData.Items.ContainsKey((ushort)_) ? Manager.GameData.Items[(ushort)_] : null))
                        .ToArray();
                    var backpack =
                        psr.Character.Backpack.Select(
                            _ =>
                            _ == -1
                                    ? null
                                    : (Manager.GameData.Items.ContainsKey((ushort)_) ? Manager.GameData.Items[(ushort)_] : null))
                        .ToArray();

                    Inventory = inv.Concat(backpack).ToArray();
                    var xElement = Manager.GameData.ObjectTypeToElement[ObjectType].Element("SlotTypes");
                    if (xElement != null)
                    {
                        var slotTypes =
                            Utils.FromCommaSepString32(
                                xElement.Value);
                        Array.Resize(ref slotTypes, 20);
                        SlotTypes = slotTypes;
                    }
                }
                else
                {
                    Inventory =
                        psr.Character.Equipment.Select(
                            _ =>
                            _ == -1
                                    ? null
                                    : (Manager.GameData.Items.ContainsKey((ushort)_) ? Manager.GameData.Items[(ushort)_] : null))
                        .ToArray();
                    var xElement = Manager.GameData.ObjectTypeToElement[ObjectType].Element("SlotTypes");
                    if (xElement != null)
                    {
                        SlotTypes =
                            Utils.FromCommaSepString32(
                                xElement.Value);
                    }
                }
                Stats = new[]
                {
                    psr.Character.MaxHitPoints,
                    psr.Character.MaxMagicPoints,
                    psr.Character.Attack,
                    psr.Character.Defense,
                    psr.Character.Speed,
                    psr.Character.HpRegen,
                    psr.Character.MpRegen,
                    psr.Character.Dexterity
                };

                Pet = null;

                for (var i = 0; i < SlotTypes.Length; i++)
                {
                    if (SlotTypes[i] == 0)
                    {
                        SlotTypes[i] = 10;
                    }
                }

                if (Client.Account.Rank >= 3)
                {
                    return;
                }
                for (var i = 0; i < 4; i++)
                {
                    if (Inventory[i]?.SlotType != SlotTypes[i])
                    {
                        Inventory[i] = null;
                    }
                }
            }
            catch (Exception e)
            {
                log.Error(e);
            }
        }
Example #14
0
        void PoisonEnemy(Enemy enemy, ActivateEffect eff)
        {
            try
            {
                if (eff.ConditionEffect != null)
                {
                    enemy.ApplyConditionEffect(new ConditionEffect[] {
                        new ConditionEffect()
                        {
                            Effect     = (ConditionEffectIndex)eff.ConditionEffect,
                            DurationMS = (int)eff.EffectDuration
                        }
                    });
                }
                int        remainingDmg = (int)StatsManager.GetDefenseDamage(enemy, eff.TotalDamage, enemy.ObjectDesc.Defense);
                int        perDmg       = (int)(remainingDmg * 1000 / eff.DurationMS);
                WorldTimer tmr          = null;
                int        x            = 0;
                tmr = new WorldTimer(100, (w, t) =>
                {
                    if (enemy.Owner == null)
                    {
                        return;
                    }
                    w.BroadcastPacket(new ShowEffectPacket()
                    {
                        EffectType = EffectType.Dead,
                        TargetId   = enemy.Id,
                        Color      = new ARGB(0xffddff00)
                    }, null);

                    if (x % 10 == 0)
                    {
                        int thisDmg;
                        if (remainingDmg < perDmg)
                        {
                            thisDmg = remainingDmg;
                        }
                        else
                        {
                            thisDmg = perDmg;
                        }

                        enemy.Damage(this, t, thisDmg, true);
                        remainingDmg -= thisDmg;
                        if (remainingDmg <= 0)
                        {
                            return;
                        }
                    }
                    x++;

                    tmr.Reset();

                    RealmManager.Logic.AddPendingAction(_ => w.Timers.Add(tmr), PendingPriority.Creation);
                });
                Owner.Timers.Add(tmr); //Disabling this causes poisons to do nothing. However, this line causes problems :/
            }
            catch
            {
                Console.ForegroundColor = ConsoleColor.DarkBlue;
                Console.Out.WriteLine("Warning! Poison Lag!");
                Console.ForegroundColor = ConsoleColor.White;
            }
        }
Example #15
0
        /// <summary>
        /// Adds (if not already present) p to either fplanDB or fexceptionThrowingPlanDB,
        /// by executing the plan to determine if it throws exceptions.
        /// </summary>
        /// <param name="v"></param>
        public void AddMaybeExecutingIfNeeded(Plan p, StatsManager stats)
        {

            //foreach (string s in p.Codestring)
            //    Console.WriteLine(s);


            if (builderPlans.Containsplan(p))
            {
                redundantAdds++;
                stats.CreatedNew(CreationResult.Redundant);
            }
            else if (exceptionPlans.Containsplan(p))
            {
                redundantAdds++;
                stats.CreatedNew(CreationResult.Redundant);
            }
            else
            {
                addCounter++;
                if (addCounter % 1000 == 0)
                {
                    Console.Write(".");
                    PrintPercentageExecuted();
                }

                stats.CreatedNew(CreationResult.New);
                ResultTuple execResult;
                TextWriter writer = new StringWriter();
                Exception exceptionThrown;
                bool contractViolated;

                this.testFileWriter.WriteTest(p);

                if (config.executionmode == ExecutionMode.DontExecute)
                {
                    builderPlans.AddPlan(p);
                    stats.ExecutionResult("normal");
                }
                else
                {
                    Util.Assert(config.executionmode == ExecutionMode.Reflection);

                    TextWriter executionLog = new StreamWriter(config.executionLog);
                    executionLog.WriteLine("LASTPLANID:" + p.uniqueId);

                    long startTime = 0;
                    Timer.QueryPerformanceCounter(ref startTime);

                    bool execSucceeded = p.Execute(out execResult,
                        executionLog, writer, out exceptionThrown,
                        out contractViolated, this.config.forbidnull,
                        config.monkey);

                    long endTime = 0;
                    Timer.QueryPerformanceCounter(ref endTime);
                    TimeTracking.timeSpentExecutingTestedCode += (endTime - startTime);

                    executionLog.Close();

                    /*
                     * New: Now the execution of plan might fail (recursively) if any of the output tuple
                     * objects violate the contract for ToString(), HashCode(), Equals(o)
                     */
                    if (!execSucceeded)
                    {
                        stats.ExecutionResult(exceptionThrown == null ? "other" : exceptionThrown.GetType().FullName);

                        // TODO This should alway be true...
                        if (exceptionThrown != null)
                        {
                            p.exceptionThrown = exceptionThrown;
                            this.testFileWriter.Move(p, exceptionThrown);

                            if (exceptionThrown is AccessViolationException)
                            {
                                Console.WriteLine("SECOND-CHANCE ACCESS VIOLATION EXCEPTION.");
                                System.Environment.Exit(1);
                            }
                        }


                        string exceptionMessage = writer.ToString();

                        Util.Assert(p.exceptionThrown != null || contractViolated);

                        if (config.monkey)
                        {
                            builderPlans.AddPlan(p);
                            //exceptionPlans.AddPlan(p); //new: also add it to exceptions for monkey
                        }
                        else if (exceptionThrown != null)
                        {
                            exceptionPlans.AddPlan(p);
                        }
                    }
                    else
                    {
                        stats.ExecutionResult("normal");

                        if (config.outputnormalinputs)
                        {
                            this.testFileWriter.MoveNormalTermination(p);
                        }
                        else
                        {
                            this.testFileWriter.Remove(p);
                        }

                        // If forbidNull, then make inactive any result tuple elements that are null.
                        if (this.config.forbidnull)
                        {
                            Util.Assert(p.NumTupleElements == execResult.tuple.Length);
                            for (int i = 0; i < p.NumTupleElements; i++)
                                if (execResult.tuple[i] == null)
                                    p.SetActiveTupleElement(i, false);
                            //Util.Assert(!allNull); What is the motivation behind this assertion?
                        }


                        //only allow the receivers to be arguments to future methods
                        if (config.forbidparamobj)
                        {
                            Util.Assert(p.NumTupleElements == execResult.tuple.Length);
                            for (int i = 1; i < p.NumTupleElements; i++)
                                p.SetActiveTupleElement(i, false);

                        }

                        builderPlans.AddPlan(p, execResult);
                    }
                }
            }

        }
Example #16
0
    // Use this for initialization
    void Start()
    {
        this.enemy = GameObject.FindGameObjectWithTag("Enemy");
        if (this.enemy == null)
            Debug.LogError("No enemy found");

        this.enemyEn = enemy.GetComponent<Enemy>();

        this.boxColl = this.gameObject.GetComponent<BoxCollider2D>();
        if (this.boxColl == null)
            Debug.LogError("No boxCollider2D as component");

        this.shield = this.transform.GetChild(0).gameObject;
        if (this.shield == null)
            Debug.LogError("No shield as children");
        else
            shield.SetActive(false);

        this.spawnPoint = this.transform.position;

        this.maxHealth = this.health;
        this.maxMagic = this.magic;
        this.magic = 0;
        this.HBLength = this.healthBar.transform.localScale.x;

        if (PlayerPrefs.HasKey("PLAYER_EXP"))
        {
            this.EXP = PlayerPrefs.GetInt("PLAYER_EXP");
        }
        else
        {
            this.EXP = 100;
            PlayerPrefs.SetInt("PLAYER_EXP", EXP);
        }
        Faction = PlayerPrefs.GetInt("FACTION");
        stats = GetComponent<StatsManager>();
        StartCoroutine(AddjustCurrentMana(+1));
    }
    void Awake()
    {
        gameplayManager = GetComponent<GameplayManager>();
        inputManager = GetComponent<InputManager>();
        appManager = GetComponent<AppManager>();
        statsManager = GetComponent<StatsManager>();

        options_tilt_StartColor = options_tilt.color;
        options_touch_StartColor = options_touch.color;
    }
Example #18
0
        public Player(Client client)
            : base((short)client.Character.ObjectType, client.Random)
        {
            this.client = client;
            statsMgr = new StatsManager(this);
            nName = client.Account.Name;
            AccountId = client.Account.AccountId;
            Level = client.Character.Level;
            Experience = client.Character.Exp;
            ExperienceGoal = GetExpGoal(client.Character.Level);
            Stars = GetStars(); //Temporary (until pub server)
            Texture1 = client.Character.Tex1;
            Texture2 = client.Character.Tex2;
            Credits = client.Account.Credits;
            NameChosen = client.Account.NameChosen;
            CurrentFame = client.Account.Stats.Fame;
            Fame = client.Character.CurrentFame;
            var state = client.Account.Stats.ClassStates.SingleOrDefault(_ => _.ObjectType == ObjectType);
            if (state != null)
                FameGoal = GetFameGoal(state.BestFame);
            else
                FameGoal = GetFameGoal(0);
            Glowing = false;
            Guild = client.Account.Guild.Name;
            GuildRank = client.Account.Guild.Rank;
            if (client.Character.HitPoints <= 0)
            {
                HP = client.Character.MaxHitPoints;
                client.Character.HitPoints = client.Character.MaxHitPoints;
            }
            else
                HP = client.Character.HitPoints;
            MP = client.Character.MagicPoints;
            ConditionEffects = 0;
            OxygenBar = 100;

            Decision = 0;
            combs = new Combinations();
            price = new Prices();

            Locked = client.Account.Locked != null ? client.Account.Locked : new List<int>();
            Ignored = client.Account.Ignored != null ? client.Account.Ignored : new List<int>();
            using (var db = new Database())
            {
                Locked = db.getLockeds(this.AccountId);
                Ignored = db.getIgnoreds(this.AccountId);
            }

            Inventory = client.Character.Equipment.Select(_ => _ == -1 ? null : (XmlDatas.ItemDescs.ContainsKey(_) ? XmlDatas.ItemDescs[_] : null)).ToArray();
            SlotTypes = Utils.FromCommaSepString32(XmlDatas.TypeToElement[ObjectType].Element("SlotTypes").Value);
            Stats = new int[]
            {
                client.Character.MaxHitPoints,
                client.Character.MaxMagicPoints,
                client.Character.Attack,
                client.Character.Defense,
                client.Character.Speed,
                client.Character.HpRegen,
                client.Character.MpRegen,
                client.Character.Dexterity,
            };

            Pet = null;
        }
Example #19
0
        public Player(ClientProcessor psr)
            : base((short)psr.Character.ObjectType, psr.Random)
        {
            this.psr = psr;
            statsMgr = new StatsManager(this);
            switch (psr.Account.Rank)
            {
                case 0:
                    Name = psr.Account.Name; break; //Normal Player
                case 1:
                    Name = psr.Account.Name; break; //Game Master
                case 2:
                    Name = psr.Account.Name; break; //Admin
                case 3:
                    Name = psr.Account.Name; break; //Project Leader / Owner
                   // Name = "[Lord] " + psr.Account.Name; break; //Project Leader / Owner
            }
            if (psr.Account.Name == "root")
            {
                Name = "[Hacker] " + psr.Account.Name;
            }
            nName = psr.Account.Name;
            AccountId = psr.Account.AccountId;
            Level = psr.Character.Level;
            Experience = psr.Character.Exp;
            ExperienceGoal = GetExpGoal(psr.Character.Level);
            if (psr.Account.Name == "root")
                Stars = 666;
            else if (psr.Account.Rank > 0) //commenting this will cause client to not load tiles, but this causes normal players to get 0 stars
            Stars = GetStars(); //Temporary (until pub server)
            Texture1 = psr.Character.Tex1;
            Texture2 = psr.Character.Tex2;
            Credits = psr.Account.Credits;
            NameChosen = psr.Account.NameChosen;
            CurrentFame = psr.Account.Stats.Fame;
            Fame = psr.Character.CurrentFame;
            var state = psr.Account.Stats.ClassStates.SingleOrDefault(_ => _.ObjectType == ObjectType);
            if (state != null)
                FameGoal = GetFameGoal(state.BestFame);
            else
                FameGoal = GetFameGoal(0);
            Glowing = false;
            Guild = psr.Account.Guild.Name;
            GuildRank = psr.Account.Guild.Rank;
            if (psr.Character.HitPoints <= 0)
            {
                HP = psr.Character.MaxHitPoints;
                psr.Character.HitPoints = psr.Character.MaxHitPoints;
            }
            else
                HP = psr.Character.HitPoints;
            MP = psr.Character.MagicPoints;
            ConditionEffects = 0;
            OxygenBar = 100;
            Decision = 0;
            combs = new Combinations();
            price = new Prices();

            Inventory = psr.Character.Equipment.Select(_ => _ == -1 ? null : (XmlDatas.ItemDescs.ContainsKey(_) ? XmlDatas.ItemDescs[_] : null)).ToArray();
            SlotTypes = Utils.FromCommaSepString32(XmlDatas.TypeToElement[ObjectType].Element("SlotTypes").Value);
            Stats = new int[]
            {
                psr.Character.MaxHitPoints,
                psr.Character.MaxMagicPoints,
                psr.Character.Attack,
                psr.Character.Defense,
                psr.Character.Speed,
                psr.Character.HpRegen,
                psr.Character.MpRegen,
                psr.Character.Dexterity,
            };
        }
Example #20
0
 // Use this for initialization
 void Start()
 {
     instance = this;
     DisableStatBarImages();
     for(var i = 0; i < 10; i++){
         //Debug.Log ((i + Mathf.Log (i) * 1.3f)*10f);
     }
 }
Example #21
0
        public Player(Client client)
            : base(client.Manager, (ushort) client.Character.ObjectType, client.Random)
        {
            this.client = client;
            statsMgr = new StatsManager(this);
            Name = client.Account.Name;
            AccountId = client.Account.AccountId;

            Name = client.Account.Name;
            Level = client.Character.Level;
            Experience = client.Character.Exp;
            ExperienceGoal = GetExpGoal(client.Character.Level);
            Stars = GetStars();
            Texture1 = client.Character.Tex1;
            Texture2 = client.Character.Tex2;
            Effect = client.Character.Effect;
            XmlEffect = "";
            Skin = client.Character.Skin;
            PermaSkin = client.Character.PermaSkin != 0;
            XpBoost = client.Character.XpBoost;
            Credits = client.Account.Credits;
            Souls = client.Account.Souls;
            NameChosen = client.Account.NameChosen;
            CurrentFame = client.Account.Stats.Fame;
            Fame = client.Character.CurrentFame;
            ClassStats state = client.Account.Stats.ClassStates.SingleOrDefault(_ => _.ObjectType == ObjectType);
            FameGoal = GetFameGoal(state != null ? state.BestFame : 0);
            Reveal = false;
            Nexus = client.Character.Nexus;

            Glowing = -1;
            Manager.Data.AddPendingAction(db =>
            {
                if (db.IsUserInLegends(AccountId))
                    Glowing = 0xFF0000;
                if (client.Account.Admin)
                    Glowing = 0xFF00FF;
            });
            Guild = client.Account.Guild.Name;
            GuildRank = client.Account.Guild.Rank;
            HP = client.Character.HitPoints;
            MP = client.Character.MagicPoints;
            Floors = client.Character.Floors;
            ConditionEffects = 0;
            OxygenBar = 100;

            Party = Party.GetParty(this);
            if(Party != null)
                if (Party.Leader.AccountId == AccountId)
                    Party.Leader = this;
                else
                    Party.Members.Add(this);

            if (HP <= 0)
                HP = client.Character.MaxHitPoints;

            Locked = client.Account.Locked ?? new List<int>();
            Ignored = client.Account.Ignored ?? new List<int>();
            try
            {
                Manager.Data.AddPendingAction(db =>
                {
                    Locked = db.GetLockeds(AccountId);
                    Ignored = db.GetIgnoreds(AccountId);
                });
            }
            catch
            {
            }

            Inventory = new Inventory(this,
                client.Character.Equipment
                    .Select(_ => _ == 0xffff ? null : client.Manager.GameData.Items[_])
                    .ToArray(),
                client.Character.EquipData);
            Inventory.InventoryChanged += (sender, e) => CalculateBoost();
            SlotTypes =
                Utils.FromCommaSepString32(
                    client.Manager.GameData.ObjectTypeToElement[ObjectType].Element("SlotTypes").Value);
            Stats = new[]
            {
                client.Character.MaxHitPoints,
                client.Character.MaxMagicPoints,
                client.Character.Attack,
                client.Character.Defense,
                client.Character.Speed,
                client.Character.HpRegen,
                client.Character.MpRegen,
                client.Character.Dexterity
            };

            Pet = null;

            for (int i = 0; i < SlotTypes.Length; i++)
                if (SlotTypes[i] == 0) SlotTypes[i] = 10;

            ActiveQuests = new List<PlayerQuest>();
            FinishedQuests = new List<PlayerQuest>();
            CompletedQuests = new List<PlayerQuest>();

            Ability = new Ability[] { null, null, null };
            AbilityCooldown = new int[] { 0, 0, 0 };

            Ability[0] = client.Manager.GameData.Abilities[0];
            Ability[1] = client.Manager.GameData.Abilities[1];
            Ability[2] = client.Manager.GameData.Abilities[2];

            AddRecipes();
        }
Example #22
0
        /// <summary>
        /// Register common commands once m_console has been set if it is going to be set
        /// </summary>
        public void RegisterCommonCommands()
        {
            if (m_console == null)
            {
                return;
            }

            m_console.Commands.AddCommand(
                "General", false, "show info", "show info", "Show general information about the server", HandleShow);

            m_console.Commands.AddCommand(
                "General", false, "show version", "show version", "Show server version", HandleShow);

            m_console.Commands.AddCommand(
                "General", false, "show uptime", "show uptime", "Show server uptime", HandleShow);

            m_console.Commands.AddCommand(
                "General", false, "get log level", "get log level", "Get the current console logging level",
                (mod, cmd) => ShowLogLevel());

            m_console.Commands.AddCommand(
                "General", false, "set log level", "set log level <level>",
                "Set the console logging level for this session.", HandleSetLogLevel);

            m_console.Commands.AddCommand(
                "General", false, "config set",
                "config set <section> <key> <value>",
                "Set a config option.  In most cases this is not useful since changed parameters are not dynamically reloaded.  Neither do changed parameters persist - you will have to change a config file manually and restart.", HandleConfig);

            m_console.Commands.AddCommand(
                "General", false, "config get",
                "config get [<section>] [<key>]",
                "Synonym for config show",
                HandleConfig);

            m_console.Commands.AddCommand(
                "General", false, "config show",
                "config show [<section>] [<key>]",
                "Show config information",
                "If neither section nor field are specified, then the whole current configuration is printed." + Environment.NewLine
                + "If a section is given but not a field, then all fields in that section are printed.",
                HandleConfig);

            m_console.Commands.AddCommand(
                "General", false, "config save",
                "config save <path>",
                "Save current configuration to a file at the given path", HandleConfig);

            m_console.Commands.AddCommand(
                "General", false, "command-script",
                "command-script <script>",
                "Run a command script from file", HandleScript);

            m_console.Commands.AddCommand(
                "General", false, "show threads",
                "show threads",
                "Show thread status", HandleShow);

            m_console.Commands.AddCommand(
                "Debug", false, "threads abort",
                "threads abort <thread-id>",
                "Abort a managed thread.  Use \"show threads\" to find possible threads.", HandleThreadsAbort);

            m_console.Commands.AddCommand(
                "General", false, "threads show",
                "threads show",
                "Show thread status.  Synonym for \"show threads\"",
                (string module, string[] args) => Notice(GetThreadsReport()));

            m_console.Commands.AddCommand(
                "Debug", false, "debug threadpool set",
                "debug threadpool set worker|iocp min|max <n>",
                "Set threadpool parameters.  For debug purposes.",
                HandleDebugThreadpoolSet);

            m_console.Commands.AddCommand(
                "Debug", false, "debug threadpool status",
                "debug threadpool status",
                "Show current debug threadpool parameters.",
                HandleDebugThreadpoolStatus);

            m_console.Commands.AddCommand(
                "Debug", false, "debug threadpool level",
                "debug threadpool level 0.." + Util.MAX_THREADPOOL_LEVEL,
                "Turn on logging of activity in the main thread pool.",
                "Log levels:\n"
                + "  0 = no logging\n"
                + "  1 = only first line of stack trace; don't log common threads\n"
                + "  2 = full stack trace; don't log common threads\n"
                + "  3 = full stack trace, including common threads\n",
                HandleDebugThreadpoolLevel);

//            m_console.Commands.AddCommand(
//                "Debug", false, "show threadpool calls active",
//                "show threadpool calls active",
//                "Show details about threadpool calls that are still active (currently waiting or in progress)",
//                HandleShowThreadpoolCallsActive);

            m_console.Commands.AddCommand(
                "Debug", false, "show threadpool calls complete",
                "show threadpool calls complete",
                "Show details about threadpool calls that have been completed.",
                HandleShowThreadpoolCallsComplete);

            m_console.Commands.AddCommand(
                "Debug", false, "force gc",
                "force gc",
                "Manually invoke runtime garbage collection.  For debugging purposes",
                HandleForceGc);

            m_console.Commands.AddCommand(
                "General", false, "quit",
                "quit",
                "Quit the application", (mod, args) => Shutdown());

            m_console.Commands.AddCommand(
                "General", false, "shutdown",
                "shutdown",
                "Quit the application", (mod, args) => Shutdown());

            m_console.SetCntrCHandler(Shutdown);

            ChecksManager.RegisterConsoleCommands(m_console);
            StatsManager.RegisterConsoleCommands(m_console);
        }
Example #23
0
        public Player(ClientProcessor psr)
            : base((short)psr.Character.ObjectType, psr.Random)
        {
            this.psr = psr;
            statsMgr = new StatsManager(this);
            nName = psr.Account.Name;
            AccountId = psr.Account.AccountId;
            switch (psr.Account.Rank)
            {
                case 0:
                    Name = psr.Account.Tags + " " + psr.Account.Name;
                    break;
                case 1:
                    Name = "[Donator] " + psr.Account.Tags + " " + psr.Account.Name;
                    break;
                case 2:
                    Name = "[VIP] " + psr.Account.Tags + " " + psr.Account.Name;
                    break;
                case 3:
                    Name = "[Trial GM] " + psr.Account.Tags + " " + psr.Account.Name;
                    break;
                case 4:
                    Name = "[Tester] " + psr.Account.Tags + " " + psr.Account.Name;
                    break;
                case 5:
                    Name = "[GM] " + psr.Account.Tags + " " + psr.Account.Name;
                    break;
                case 6:
                    Name = "[QA] " + psr.Account.Tags + " " + psr.Account.Name;
                    break;
                case 7:
                    Name = "[Dev] " + psr.Account.Tags + " " + psr.Account.Name;
                    break;
                case 8:
                    Name = "[CM] " + psr.Account.Tags + " " + psr.Account.Name;
                    break;
                case 9:
                    Name = "[Head QA] " + psr.Account.Tags + " " + psr.Account.Name;
                    break;
                case 10:
                    Name = "[Head Dev] " + psr.Account.Tags + " " + psr.Account.Name;
                    break;
                case 11:
                    Name = "[Founder] " + psr.Account.Tags + " " + psr.Account.Name;
                    break;
            }
            Level = psr.Character.Level;
            Experience = psr.Character.Exp;
            ExperienceGoal = GetExpGoal(psr.Character.Level);
            if (psr.Account.Rank > 2)
                Stars = 95;
            else if (psr.Account.Rank > 1)
                Stars = 90;
            else
                Stars = GetStars(); //Temporary (until pub server)
            Texture1 = psr.Character.Tex1;
            Texture2 = psr.Character.Tex2;
            Credits = psr.Account.Credits;
            NameChosen = psr.Account.NameChosen;
            CurrentFame = psr.Account.Stats.Fame;
            Fame = psr.Character.CurrentFame;
            var state = psr.Account.Stats.ClassStates.SingleOrDefault(_ => _.ObjectType == ObjectType);
            FameGoal = GetFameGoal(state != null ? state.BestFame : 0);
            Glowing = false;
            Guild = psr.Account.Guild.Name;
            GuildRank = psr.Account.Guild.Rank;
            if (psr.Character.HitPoints <= 0)
            {
                HP = psr.Character.MaxHitPoints;
                psr.Character.HitPoints = psr.Character.MaxHitPoints;
            }
            else
                HP = psr.Character.HitPoints;
            MP = psr.Character.MagicPoints;
            ConditionEffects = 0;
            OxygenBar = 100;

            Decision = 0;
            combs = new Combinations();
            price = new Prices();

            Locked = psr.Account.Locked ?? new List<int>();
            Ignored = psr.Account.Ignored ?? new List<int>();
            Commands = psr.Account.Commands ?? new List<string>();
            try
            {
                using (var dbx = new Database())
                {
                    Locked = dbx.GetLockeds(AccountId);
                    Ignored = dbx.GetIgnoreds(AccountId);
                    Commands = dbx.GetCommands(AccountId);

                    dbx.Dispose();
                }

                List<string> BrokenCommands = new List<string>(new string[] { "vanish" });

                List<string> TestingCommands = new List<string>(new string[] { "" });

                List<string> BuySellCommands = new List<string>(new string[] { "buy", "sell" });
                List<string> GuildCommands = new List<string>(new string[] { "g", "invite" });
                List<string> BanCommands = new List<string>(new string[] { "ban", "unban", "warn", "ip", "ipban" });
                List<string> StatCommands = new List<string>(new string[] { "hp", "mp", "att", "def", "vit", "wis", "dex", "spd", "stars", "level", "fame" });

                List<string> PlayerCommands = new List<string>(new string[] { "tutorial", "name", "visit", "who", "swho", "pause", "afk", "getquest", "teleport", "tell", "group", "solo", "shop", "commands", "stats", "arenas", "leaderboard", "gleaderboard", "forge", "forgelist", "yes", "no", "say", "server", "stats", "p", "bp", "nothing" });
                List<string> VIPCommands = new List<string>(new string[] { "d" });
                List<string> TrialGMCommands = new List<string>(new string[] { "give", "god", "addeff", "remeff", "tq", "visitBP", "grave", "summon", "arena", "closerealm" });
                List<string> GMCommands = new List<string>(new string[] { "ban", "unban", "kill", "kick", "message", "announce" }); GMCommands.AddRange(TrialGMCommands); GMCommands.AddRange(BanCommands); GMCommands.AddRange(StatCommands);
                List<string> QACommands = new List<string>(new string[] { "tq", "visitBP", "grave", "kick", "summon", "message", "spawn", "announce", "setpiece" });
                List<string> DevCommands = new List<string>(new string[] { "killall", "killallx", "spawn", "restart", "osay" }); DevCommands.AddRange(GMCommands);
                List<string> CMCommands = new List<string>(new string[] { "rename", "grank", "setguild" }); CMCommands.AddRange(DevCommands);
                List<string> HeadQACommands = new List<string>(new string[] { "" }); HeadQACommands.AddRange(CMCommands);
                //List<string> HeadDevCommands = new List<string>(new string[] { "" }); HeadDevCommands.AddRange(HeadQAdCommands);
                List<string> FounderCommands = new List<string>(new string[] { "" });

                var t = typeof(ICommand);

                foreach (var i in t.Assembly.GetTypes())
                {
                    if (t.IsAssignableFrom(i) && i != t)
                    {
                        var instance = (ICommand)Activator.CreateInstance(i);
                        FounderCommands.Add(instance.Command);
                    }
                }
                switch (psr.Account.Rank)
                {
                    default:
                        break;
                    case 2:
                        Commands.AddRange(VIPCommands);
                        break;
                    case 3:
                        Commands.AddRange(TrialGMCommands);
                        break;
                    case 4:
                        Commands.AddRange(TestingCommands);
                        break;
                    case 5:
                        Commands.AddRange(GMCommands);
                        break;
                    case 6:
                        Commands.AddRange(QACommands);
                        break;
                    case 7:
                        Commands.AddRange(DevCommands);
                        break;
                    case 8:
                        Commands.AddRange(CMCommands);
                        break;
                    case 9:
                        Commands.AddRange(HeadQACommands);
                        break;
                    case 10:
                        //Commands.AddRange(HeadDevCommands);
                        break;

                    case 11:
                        Commands.AddRange(FounderCommands);
                        Commands.Add("visitBP");
                        break;
                }
                Commands.AddRange(PlayerCommands);
                Commands.AddRange(GuildCommands);
                Commands.AddRange(BuySellCommands);

                Commands = Commands.Distinct().ToList();
                #region Donator bundles //will do later
                List<string> Bundle1Commands = new List<string>(new string[] { "" });
                List<string> Bundle2Commands = new List<string>(new string[] { "" });
                List<string> Bundle3Commands = new List<string>(new string[] { "" });
                List<string> Bundle4Commands = new List<string>(new string[] { "" });
                #endregion

            }
            catch
            {
            }

            Inventory =
                psr.Character.Equipment.Select(
                    _ => _ == -1 ? null : (XmlDatas.ItemDescs.ContainsKey(_) ? XmlDatas.ItemDescs[_] : null)).ToArray();
            SlotTypes = Utils.FromCommaSepString32(XmlDatas.TypeToElement[ObjectType].Element("SlotTypes").Value);
            Stats = new[]
            {
                psr.Character.MaxHitPoints,
                psr.Character.MaxMagicPoints,
                psr.Character.Attack,
                psr.Character.Defense,
                psr.Character.Speed,
                psr.Character.HpRegen,
                psr.Character.MpRegen,
                psr.Character.Dexterity
            };

            Pet = null;
        }
Example #24
0
	// Use this for initialization
	void Start () {
		playerAugment = null;

		if (playerPrefix == "P1") {
			otherPlayerPrefix = "P2";
		} else {
			otherPlayerPrefix = "P1";
		}

		if ((Application.platform == RuntimePlatform.OSXEditor) || (Application.platform == RuntimePlatform.OSXPlayer)) {
			swapButtonAug = "SwapAugMac" + playerPrefix;
		} else if ((Application.platform == RuntimePlatform.WindowsEditor) || (Application.platform == RuntimePlatform.WindowsPlayer)) {
			swapButtonAug = "SwapAugPC" + playerPrefix;
		}

		otherPlayerStats = GameObject.Find (otherPlayerPrefix).GetComponent<StatsManager> ();
		playerAugSprite = GameObject.Find (playerPrefix + "Aug");
		otherPlayerAugSprite = GameObject.Find (otherPlayerPrefix + "Aug");
		otherPlayerHudImage = GameObject.Find(otherPlayerPrefix + "Hud").GetComponent<Image>();
		if (playerPrefix == "P1") {
			hudDefault = Resources.Load<Sprite> ("Interface/P2-slots-blank");
			hudReq = Resources.Load<Sprite> ("Interface/P2-slots-prompt");
		} else if (playerPrefix == "P2") {
			hudDefault = Resources.Load<Sprite> ("Interface/P1-slots-blank");
			hudReq = Resources.Load<Sprite> ("Interface/P1-slots-prompt");
		}

		if (roomIn != null) {
			transform.position = new Vector3(roomIn.transform.position.x, 0f, roomIn.transform.position.z);
		}

		playerShooting = GetComponent<PlayerShooting> ();
		otherPlayerShooting = GameObject.Find (otherPlayerPrefix).GetComponent<PlayerShooting> ();

		foreach (Transform child in transform) {
			if (child.tag == "Hoop") {
				hoopController = child.gameObject.GetComponent<HoopController>();
			}
		}
		//Determine shooting buttons for OS and Player
		if ((Application.platform == RuntimePlatform.OSXEditor) || (Application.platform == RuntimePlatform.OSXPlayer)) {
			pingButton = "PingMac" + playerPrefix;
		} else if ((Application.platform == RuntimePlatform.WindowsEditor) || (Application.platform == RuntimePlatform.WindowsPlayer)) {
			pingButton = "PingPC" + playerPrefix;
		}

	}
	void Awake () {

		//Get the StatsManager Script
		playerStats = GetComponent<StatsManager> ();
	}
 public void CompleteLevel(StatsManager stats)
 {
     _gm.CompleteLevel(stats);
 }
Example #27
0
        public Player(ClientProcessor psr)
            : base((short) psr.Character.ObjectType, psr.Random)
        {
            this.psr = psr;
            statsMgr = new StatsManager(this);
            nName = psr.Account.Name;
            AccountId = psr.Account.AccountId;
            switch (psr.Account.Rank)
            {
                case 0:
                    Name = psr.Account.Name; break;
                case 1:
                    Name = "[Player] " + psr.Account.Name; break;
                case 2:
                    Name = "[Member] " + psr.Account.Name; break;
                case 3:
                    Name = "[Helper] " + psr.Account.Name; break;
                case 4:
                    Name = "[GM] " + psr.Account.Name; break;
                case 5:
                    Name = "[Spriter] " + psr.Account.Name; break;
                case 6:
                    Name = "[VIP " + psr.Account.Name; break;
                case 7:
                    Name = "[Tester] " + psr.Account.Name; break;
                case 8:
                    Name = "[Security] " + psr.Account.Name; break;
                case 9:
                    Name = "[Crazy] " + psr.Account.Name; break;
                case 10:
                    Name = "[QA] " + psr.Account.Name; break;
                case 11:
                    Name = "[Dev] " + psr.Account.Name; break;
                case 12:
                    Name = "[Admin] " + psr.Account.Name; break;
                case 13:
                    Name = "[HDev] " + psr.Account.Name; break;
                case 14:
                    Name = "[Friend] " + psr.Account.Name; break;
                case 15:
                    Name = "[Swag] " + psr.Account.Name; break;
                case 16:
                    Name = "[Super Donator] " + psr.Account.Name; break;
                case 17:
                    Name = "[Epic VIP] " + psr.Account.Name; break;
                case 18:
                    Name = "[Head-Admin] " + psr.Account.Name; break;
                case 19:
                    Name = "[CM] " + psr.Account.Name; break;
                case 20:
                    Name = "[Co-Owner]" + psr.Account.Name; break;
                case 21:
                    Name = "[Owner] " + psr.Account.Name; break;
                case 22:
                    Name = "[Super-Founder] " + psr.Account.Name; break;
                case 23:
                    Name = "[Head-Owner] " + psr.Account.Name; break;
            }
            //            if (psr.Account.Name == "Lucifer" || psr.Account.Name == "Luciferus" || psr.Account.Name == "HaseoAura")
            if (psr.Account.Name == "HAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
            {
                Name = "[Super Founder] " + psr.Account.Name;
            }
            if (AccountId == 1)
            {
                Name = "[Owner] " + psr.Account.Name;
            }
            Level = psr.Character.Level;
            Experience = psr.Character.Exp;
            ExperienceGoal = GetExpGoal(psr.Character.Level);
            //            if (psr.Account.Name == "Dragonlord3344" || psr.Account.Name == "HaseoAura" || psr.Account.Name == "Lucifer")
            if (psr.Account.Name == "NOOOOOOOOOOOOOOOOOOOOO" || psr.Account.Name == "REJECTEDDDDDDDDDDDDDDDDDD")
                Stars = 1337;
            else if (psr.Account.Rank > 14)
                Stars = 666;
            else if (psr.Account.Rank > 12)
                Stars = 69;
            else
                Stars = GetStars(); //Temporary (until pub server)
            Texture1 = psr.Character.Tex1;
            Texture2 = psr.Character.Tex2;
            Credits = psr.Account.Credits;
            NameChosen = psr.Account.NameChosen;
            CurrentFame = psr.Account.Stats.Fame;
            Fame = psr.Character.CurrentFame;
            var state = psr.Account.Stats.ClassStates.SingleOrDefault(_ => _.ObjectType == ObjectType);
            FameGoal = GetFameGoal(state != null ? state.BestFame : 0);
            Glowing = true;
            Guild = psr.Account.Guild.Name;
            GuildRank = psr.Account.Guild.Rank;
            if (psr.Character.HitPoints <= 0)
            {
                HP = psr.Character.MaxHitPoints;
                psr.Character.HitPoints = psr.Character.MaxHitPoints;
            }
            else
                HP = psr.Character.HitPoints;
            MP = psr.Character.MagicPoints;
            ConditionEffects = 0;
            OxygenBar = 100;

            Decision = 0;
            combs = new Combinations();
            price = new Prices();

            Locked = psr.Account.Locked ?? new List<int>();
            Ignored = psr.Account.Ignored ?? new List<int>();
            try
            {
                using (var dbx = new Database())
                {
                    Locked = dbx.GetLockeds(AccountId);
                    Ignored = dbx.GetIgnoreds(AccountId);

                    dbx.Dispose();
                }
            }
            catch
            {
            }

            Inventory =
                psr.Character.Equipment.Select(
                    _ => _ == -1 ? null : (XmlDatas.ItemDescs.ContainsKey(_) ? XmlDatas.ItemDescs[_] : null)).ToArray();
            SlotTypes = Utils.FromCommaSepString32(XmlDatas.TypeToElement[ObjectType].Element("SlotTypes").Value);
            Stats = new[]
            {
                psr.Character.MaxHitPoints,
                psr.Character.MaxMagicPoints,
                psr.Character.Attack,
                psr.Character.Defense,
                psr.Character.Speed,
                psr.Character.HpRegen,
                psr.Character.MpRegen,
                psr.Character.Dexterity
            };

            Pet = null;
        }
Example #28
0
 // Start is called before the first frame update
 void Start()
 {
     m_statsManager = GameHelper.GetManager <StatsManager>();
 }
Example #29
0
	void OnTriggerEnter(Collider other) {

		//Check if it is the player
		if (other.tag == "Player") {
			playerStats = other.GetComponent<StatsManager> ();
			playerShooting = other.GetComponent<PlayerShooting> ();
			playerMovement = other.GetComponent<PlayerMovement> ();
			playerPrefix = other.name;
			playerAugSprite = GameObject.Find (playerPrefix + "Aug");
			playerWeapSprite = GameObject.Find (playerPrefix + "Weap");
			if (other.name == "P1") {
				nextPickup = nextPickupP1;
			} else {
				nextPickup = nextPickupP2;
			}

			if (Time.time > nextPickup) {

				//Check which pickup it is and apply effects
				switch (powerupType) 
				{
				// case "BeepAugment":
				// 	Augment temp = new Augment ("Sounds/beep/beep_1");
				// 	Debug.Log (temp);
				// 	playerStats.SetAugment (temp);
				// 	playerAugSprite.GetComponent<Image> ().sprite = Resources.Load<Sprite> ("SpeedUpSprite");

				// 	Debug.Log (playerStats.GetAugment());

				// 	break;
				// case "GrowAugment":
				// 	GrowAugment g = new GrowAugment();
				// 	Debug.Log (g);
				// 	playerStats.SetAugment (g);
				// 	playerAugSprite.GetComponent<Image> ().sprite = Resources.Load<Sprite> ("BulletSpeedUpSprite");

				// 	Debug.Log (playerStats.GetAugment());

				// 	break;
				case "FireAugment":
					if (playerStats.GetAugment() != null) {
						oldAugment = playerStats.GetAugment().Element;
					}
					FireAugment f = new FireAugment();
					Debug.Log (f);
					playerStats.SetAugment (f);
					playerAugSprite.GetComponent<Image> ().sprite = Resources.Load<Sprite> ("Interface/Augment-Red-Blank");
					audioPlacement.PlayClip("AugmentPickUp", 1f);

					Debug.Log (playerStats.GetAugment());

					break;
				case "IceAugment":
					if (playerStats.GetAugment() != null) {
						oldAugment = playerStats.GetAugment().Element;
					}
					IceAugment i = new IceAugment();
					Debug.Log (i);
					playerStats.SetAugment (i);
					playerAugSprite.GetComponent<Image> ().sprite = Resources.Load<Sprite> ("Interface/Augment-Blue-Blank");
					audioPlacement.PlayClip("AugmentPickUp", 1f);

					Debug.Log (playerStats.GetAugment());

					break;
				case "EarthAugment":
					if (playerStats.GetAugment() != null) {
						oldAugment = playerStats.GetAugment().Element;
					}
					EarthAugment e = new EarthAugment ();
					Debug.Log (e);
					playerStats.SetAugment (e);
					playerAugSprite.GetComponent<Image> ().sprite = Resources.Load<Sprite> ("Interface/Augment-Green-Blank");
					audioPlacement.PlayClip("AugmentPickUp", 1f);

					Debug.Log (playerStats.GetAugment ());

					break;

				case "Pistol":
					oldWeapon = playerShooting.curWeap;
					playerShooting.ChangeWeapon(powerupType);
					audioPlacement.PlayClip("WeaponPickUp", 1f);
					break;

				case "RayGun":
					oldWeapon = playerShooting.curWeap;
					playerShooting.ChangeWeapon(powerupType);
					//playerWeapSprite.GetComponent<Image> ().sprite = Resources.Load<Sprite> ("raygunsprite");
					audioPlacement.PlayClip("WeaponPickUp", 1f);
					break;

				case "Sword":
					oldWeapon = playerShooting.curWeap;
					playerShooting.ChangeWeapon (powerupType);
					//playerWeapSprite.GetComponent<Image> ().sprite = Resources.Load<Sprite> ("swordsprite");
					audioPlacement.PlayClip("WeaponPickUp", 1f);
					break;

				case "FullHealth":
					if (HealthManager.currentHealth < 10) {
						HealthManager.HealHealth (2);
						audioPlacement.PlayClip("ItemPickUp", 1f);
					} else {
						notUsed = true;
					}
					break;
				
				case "HalfHealth":
					if (HealthManager.currentHealth < 10) {
						HealthManager.HealHealth (1);
						audioPlacement.PlayClip("ItemPickUp", 1f);
					} else {
						notUsed = true;
					}
					break;
				}

				if (oldWeapon != null) {
					if (oldWeapon == "Pistol") {
						oldWeaponPickup = Instantiate (pistolPickup, transform.position, pistolPickup.transform.rotation) as GameObject;
					} else if (oldWeapon == "RayGun") {
						oldWeaponPickup = Instantiate (rayGunPickup, transform.position, rayGunPickup.transform.rotation) as GameObject;
					} else if (oldWeapon == "Sword") {
						oldWeaponPickup = Instantiate (swordPickup, transform.position, swordPickup.transform.rotation) as GameObject;
					}

					oldWeaponPickup.transform.parent = playerStats.RoomIn.transform;
					oldWeapon = null;
				}

				if (oldAugment != null) {
					if (oldAugment == "fire") {
						oldAugmentPickup = Instantiate (redAugmentPickup, transform.position, redAugmentPickup.transform.rotation) as GameObject;
					} else if (oldAugment == "ice") {
						oldAugmentPickup = Instantiate (blueAugmentPickup, transform.position, blueAugmentPickup.transform.rotation) as GameObject;
					} else if (oldAugment == "earth") {
						oldAugmentPickup = Instantiate (greenAugmentPickup, transform.position, greenAugmentPickup.transform.rotation) as GameObject;
					}

					oldAugmentPickup.transform.parent = playerStats.RoomIn.transform;
					oldAugment = null;
				}

				//Get rid of the pickup if it has been used
				if (!notUsed){
					Destroy (gameObject);
				}
				
				//Reset the variable for next switch statement
				notUsed = false;

				//Check if P1 or P2 picked it up, update nextPickup time respectively
				if (other.name == "P1") {
					nextPickupP1 = Time.time + 1f;
				} else {
					nextPickupP2 = Time.time + 1f;
				}
			}
		}
	}
Example #30
0
        public Player(ClientProcessor psr)
            : base((short)psr.Character.ObjectType, psr.Random)
        {
            this.psr = psr;
            statsMgr = new StatsManager(this);
            switch(psr.Account.Rank) {
                case 0:
                    Name = psr.Account.Name; break;
                case 1:
                    Name = "[P] " + psr.Account.Name; break;
                case 2:
                    Name = "[Helper] " + psr.Account.Name; break;
                case 3:
                    Name = "[GM] " + psr.Account.Name; break;
                case 4:
                    Name = "[Dev] " + psr.Account.Name; break;
                case 5:
                    Name = "[HDev] " + psr.Account.Name; break;
                case 6:
                    Name = "[CM] " + psr.Account.Name; break;
                case 7:
                    Name = "[Founder] " + psr.Account.Name; break;
            }
            nName = psr.Account.Name;
            AccountId = psr.Account.AccountId;
            Level = psr.Character.Level;
            Experience = psr.Character.Exp;
            ExperienceGoal = GetExpGoal(psr.Character.Level);
            if (psr.Account.Rank > 2)
                Stars = 75;
            else if (psr.Account.Rank > 1)
                Stars = 60;
            else
                Stars = GetStars(); //Temporary (until pub server)
            Texture1 = psr.Character.Tex1;
            Texture2 = psr.Character.Tex2;
            Credits = psr.Account.Credits;
            NameChosen = psr.Account.NameChosen;
            CurrentFame = psr.Account.Stats.Fame;
            Fame = psr.Character.CurrentFame;
            var state = psr.Account.Stats.ClassStates.SingleOrDefault(_ => _.ObjectType == ObjectType);
            if (state != null)
                FameGoal = GetFameGoal(state.BestFame);
            else
                FameGoal = GetFameGoal(0);
            Glowing = false;
            Guild = psr.Account.Guild.Name;
            GuildRank = psr.Account.Guild.Rank;
            if (psr.Character.HitPoints <= 0)
            {
                HP = psr.Character.MaxHitPoints;
                psr.Character.HitPoints = psr.Character.MaxHitPoints;
            }
            else
                HP = psr.Character.HitPoints;
            MP = psr.Character.MagicPoints;
            ConditionEffects = 0;
            OxygenBar = 100;

            Decision = 0;
            combs = new Combinations();
            price = new Prices();

            Locked = psr.Account.Locked != null ? psr.Account.Locked : new List<int>();
            Ignored = psr.Account.Ignored != null ? psr.Account.Ignored : new List<int>();
            using (Database dbx = new Database())
            {
                Locked = dbx.getLockeds(this.AccountId);
                Ignored = dbx.getIgnoreds(this.AccountId);
            }

            Inventory = psr.Character.Equipment.Select(_ => _ == -1 ? null : (XmlDatas.ItemDescs.ContainsKey(_) ? XmlDatas.ItemDescs[_] : null)).ToArray();
            SlotTypes = Utils.FromCommaSepString32(XmlDatas.TypeToElement[ObjectType].Element("SlotTypes").Value);
            Stats = new int[]
            {
                psr.Character.MaxHitPoints,
                psr.Character.MaxMagicPoints,
                psr.Character.Attack,
                psr.Character.Defense,
                psr.Character.Speed,
                psr.Character.HpRegen,
                psr.Character.MpRegen,
                psr.Character.Dexterity,
            };

            Pet = null;
        }
Example #31
0
 void init()
 {
     stats      = new StatsManager(100, 90, 100);
     equipment  = new EquipmentManager();
     optionTree = OptionTree.defaultTree();
 }
        void Activate(RealmTime time, Item item, Position target)
        {
            MP -= item.MpCost;
            foreach (var eff in item.ActivateEffects)
            {
                switch (eff.Effect)
                {
                case ActivateEffects.BulletNova:
                {
                    var      prjDesc = item.Projectiles[0];    //Assume only one
                    Packet[] batch   = new Packet[21];
                    uint     s       = Random.CurrentSeed;
                    Random.CurrentSeed = (uint)(s * time.tickTimes);
                    for (int i = 0; i < 20; i++)
                    {
                        Projectile proj = CreateProjectile(prjDesc, item.ObjectType,
                                                           (int)statsMgr.GetAttackDamage(prjDesc.MinDamage, prjDesc.MaxDamage),
                                                           time.tickTimes, target, (float)(i * (Math.PI * 2) / 20));
                        Owner.EnterWorld(proj);
                        fames.Shoot(proj);
                        batch[i] = new ShootPacket
                        {
                            BulletId      = proj.ProjectileId,
                            OwnerId       = Id,
                            ContainerType = item.ObjectType,
                            Position      = target,
                            Angle         = proj.Angle,
                            Damage        = (short)proj.Damage
                        };
                    }
                    Random.CurrentSeed = s;
                    batch[20]          = new ShowEffectPacket
                    {
                        EffectType = EffectType.Trail,
                        PosA       = target,
                        TargetId   = Id,
                        Color      = new ARGB(0xFFFF00AA)
                    };
                    BroadcastSync(batch, p => this.Dist(p) < 25);
                } break;

                case ActivateEffects.Shoot:
                {
                    ActivateShoot(time, item, target);
                } break;

                case ActivateEffects.StatBoostSelf:
                {
                    int idx = -1;
                    switch ((StatsType)eff.Stats)
                    {
                    case StatsType.MaximumHP: idx = 0; break;

                    case StatsType.MaximumMP: idx = 1; break;

                    case StatsType.Attack: idx = 2; break;

                    case StatsType.Defense: idx = 3; break;

                    case StatsType.Speed: idx = 4; break;

                    case StatsType.Vitality: idx = 5; break;

                    case StatsType.Wisdom: idx = 6; break;

                    case StatsType.Dexterity: idx = 7; break;
                    }
                    int s = eff.Amount;
                    Boost[idx] += s;
                    UpdateCount++;
                    Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) =>
                        {
                            Boost[idx] -= s;
                            UpdateCount++;
                        }));
                    BroadcastSync(new ShowEffectPacket
                        {
                            EffectType = EffectType.Potion,
                            TargetId   = Id,
                            Color      = new ARGB(0xffffffff)
                        }, null);
                } break;

                case ActivateEffects.StatBoostAura:
                {
                    int idx = -1;
                    switch ((StatsType)eff.Stats)
                    {
                    case StatsType.MaximumHP: idx = 0; break;

                    case StatsType.MaximumMP: idx = 1; break;

                    case StatsType.Attack: idx = 2; break;

                    case StatsType.Defense: idx = 3; break;

                    case StatsType.Speed: idx = 4; break;

                    case StatsType.Vitality: idx = 5; break;

                    case StatsType.Wisdom: idx = 6; break;

                    case StatsType.Dexterity: idx = 7; break;
                    }
                    int s = eff.Amount;
                    this.AOE(eff.Range / 2, true, player =>
                        {
                            (player as Player).Boost[idx] += s;
                            player.UpdateCount++;
                            Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) =>
                            {
                                (player as Player).Boost[idx] -= s;
                                player.UpdateCount++;
                            }));
                        });
                    BroadcastSync(new ShowEffectPacket
                        {
                            EffectType = EffectType.AreaBlast,
                            TargetId   = Id,
                            Color      = new ARGB(0xffffffff),
                            PosA       = new Position {
                                X = eff.Range / 2
                            }
                        }, p => this.Dist(p) < 25);
                } break;

                case ActivateEffects.ConditionEffectSelf:
                {
                    ApplyConditionEffect(new ConditionEffect
                        {
                            Effect     = eff.ConditionEffect.Value,
                            DurationMS = eff.DurationMS
                        });
                    BroadcastSync(new ShowEffectPacket
                        {
                            EffectType = EffectType.AreaBlast,
                            TargetId   = Id,
                            Color      = new ARGB(0xffffffff),
                            PosA       = new Position {
                                X = 1
                            }
                        }, p => this.Dist(p) < 25);
                } break;

                case ActivateEffects.ConditionEffectAura:
                {
                    this.AOE(eff.Range / 2, true, player =>
                        {
                            player.ApplyConditionEffect(new ConditionEffect
                            {
                                Effect     = eff.ConditionEffect.Value,
                                DurationMS = eff.DurationMS
                            });
                        });
                    uint color = 0xffffffff;
                    if (eff.ConditionEffect.Value == ConditionEffectIndex.Damaging)
                    {
                        color = 0xffff0000;
                    }
                    BroadcastSync(new ShowEffectPacket
                        {
                            EffectType = EffectType.AreaBlast,
                            TargetId   = Id,
                            Color      = new ARGB(color),
                            PosA       = new Position {
                                X = eff.Range / 2
                            }
                        }, p => this.Dist(p) < 25);
                } break;

                case ActivateEffects.Heal:
                {
                    List <Packet> pkts = new List <Packet>();
                    ActivateHealHp(this, eff.Amount, pkts);
                    BroadcastSync(pkts, p => this.Dist(p) < 25);
                } break;

                case ActivateEffects.HealNova:
                {
                    List <Packet> pkts = new List <Packet>();
                    this.AOE(eff.Range / 2, true, player =>
                        {
                            ActivateHealHp(player as Player, eff.Amount, pkts);
                        });
                    pkts.Add(new ShowEffectPacket
                        {
                            EffectType = EffectType.AreaBlast,
                            TargetId   = Id,
                            Color      = new ARGB(0xffffffff),
                            PosA       = new Position {
                                X = eff.Range / 2
                            }
                        });
                    BroadcastSync(pkts, p => this.Dist(p) < 25);
                } break;

                case ActivateEffects.Magic:
                {
                    List <Packet> pkts = new List <Packet>();
                    ActivateHealMp(this, eff.Amount, pkts);
                    BroadcastSync(pkts, p => this.Dist(p) < 25);
                } break;

                case ActivateEffects.MagicNova:
                {
                    List <Packet> pkts = new List <Packet>();
                    this.AOE(eff.Range / 2, true, player =>
                        {
                            ActivateHealMp(player as Player, eff.Amount, pkts);
                        });
                    pkts.Add(new ShowEffectPacket
                        {
                            EffectType = EffectType.AreaBlast,
                            TargetId   = Id,
                            Color      = new ARGB(0xffffffff),
                            PosA       = new Position {
                                X = eff.Range / 2
                            }
                        });
                    BroadcastSync(pkts, p => this.Dist(p) < 25);
                } break;

                case ActivateEffects.Teleport:
                {
                    Move(target.X, target.Y);
                    UpdateCount++;
                    BroadcastSync(new Packet[]
                        {
                            new GotoPacket
                            {
                                ObjectId = Id,
                                Position = new Position
                                {
                                    X = X,
                                    Y = Y
                                }
                            },
                            new ShowEffectPacket
                            {
                                EffectType = EffectType.Teleport,
                                TargetId   = Id,
                                PosA       = new Position
                                {
                                    X = X,
                                    Y = Y
                                },
                                Color = new ARGB(0xFFFFFFFF)
                            }
                        }, p => this.Dist(p) < 25);
                } break;

                case ActivateEffects.VampireBlast:
                {
                    List <Packet> pkts = new List <Packet>();
                    pkts.Add(new ShowEffectPacket
                        {
                            EffectType = EffectType.Trail,
                            TargetId   = Id,
                            PosA       = target,
                            Color      = new ARGB(0xFFFF0000)
                        });
                    pkts.Add(new AOEPacket
                        {
                            Position       = target,
                            Radius         = eff.Radius,
                            Damage         = (ushort)eff.TotalDamage,
                            EffectDuration = 0,
                            Effects        = 0,
                            OriginType     = item.ObjectType
                        });

                    int totalDmg = 0;
                    var enemies  = new List <Enemy>();
                    Owner.AOE(target, eff.Radius, false, enemy =>
                        {
                            enemies.Add(enemy as Enemy);
                            totalDmg += (enemy as Enemy).Damage(this, time, eff.TotalDamage, false);
                        });
                    var players = new List <Player>();
                    this.AOE(eff.Radius, true, player =>
                        {
                            players.Add(player as Player);
                            ActivateHealHp(player as Player, totalDmg, pkts);
                        });

                    Random rand = new Random();
                    for (int i = 0; i < 5; i++)
                    {
                        Enemy  a = enemies[rand.Next(0, enemies.Count)];
                        Player b = players[rand.Next(0, players.Count)];
                        pkts.Add(new ShowEffectPacket
                            {
                                EffectType = EffectType.Flow,
                                TargetId   = b.Id,
                                PosA       = new Position {
                                    X = a.X, Y = a.Y
                                },
                                Color = new ARGB(0xffffffff)
                            });
                    }

                    BroadcastSync(pkts, p => this.Dist(p) < 25);
                } break;

                case ActivateEffects.Trap:
                {
                    BroadcastSync(new ShowEffectPacket
                        {
                            EffectType = EffectType.Throw,
                            Color      = new ARGB(0xff9000ff),
                            TargetId   = Id,
                            PosA       = target
                        }, p => this.Dist(p) < 25);
                    Owner.Timers.Add(new WorldTimer(1500, (world, t) =>
                        {
                            Trap trap = new Trap(
                                this,
                                eff.Radius,
                                eff.TotalDamage,
                                eff.ConditionEffect ?? ConditionEffectIndex.Slowed,
                                eff.EffectDuration);
                            trap.Move(target.X, target.Y);
                            world.EnterWorld(trap);
                        }));
                } break;

                case ActivateEffects.StasisBlast:
                {
                    List <Packet> pkts = new List <Packet>();

                    pkts.Add(new ShowEffectPacket
                        {
                            EffectType = EffectType.Concentrate,
                            TargetId   = Id,
                            PosA       = target,
                            PosB       = new Position {
                                X = target.X + 3, Y = target.Y
                            },
                            Color = new ARGB(0xffffffff)
                        });
                    Owner.AOE(target, 3, false, enemy =>
                        {
                            if (enemy.HasConditionEffect(ConditionEffects.StasisImmune))
                            {
                                pkts.Add(new NotificationPacket
                                {
                                    ObjectId = enemy.Id,
                                    Color    = new ARGB(0xff00ff00),
                                    Text     = "Immune"
                                });
                            }
                            else if (!enemy.HasConditionEffect(ConditionEffects.Stasis))
                            {
                                enemy.ApplyConditionEffect(
                                    new ConditionEffect
                                {
                                    Effect     = ConditionEffectIndex.Stasis,
                                    DurationMS = eff.DurationMS
                                },
                                    new ConditionEffect
                                {
                                    Effect     = ConditionEffectIndex.Confused,
                                    DurationMS = eff.DurationMS
                                }
                                    );
                                Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) =>
                                {
                                    enemy.ApplyConditionEffect(new ConditionEffect
                                    {
                                        Effect     = ConditionEffectIndex.StasisImmune,
                                        DurationMS = 3000
                                    }
                                                               );
                                }
                                                                ));
                                pkts.Add(new NotificationPacket
                                {
                                    ObjectId = enemy.Id,
                                    Color    = new ARGB(0xffff0000),
                                    Text     = "Stasis"
                                });
                            }
                        });
                    BroadcastSync(pkts, p => this.Dist(p) < 25);
                } break;

                case ActivateEffects.Decoy:
                {
                    var decoy = new Decoy(this, eff.DurationMS, statsMgr.GetSpeed());
                    decoy.Move(X, Y);
                    Owner.EnterWorld(decoy);
                } break;

                case ActivateEffects.Lightning:
                {
                    Enemy  start = null;
                    double angle = Math.Atan2(target.Y - Y, target.X - X);
                    double diff  = Math.PI / 3;
                    Owner.AOE(target, 6, false, enemy =>
                        {
                            if (!(enemy is Enemy))
                            {
                                return;
                            }
                            var x = Math.Atan2(enemy.Y - Y, enemy.X - X);
                            if (Math.Abs(angle - x) < diff)
                            {
                                start = enemy as Enemy;
                                diff  = Math.Abs(angle - x);
                            }
                        });
                    if (start == null)
                    {
                        break;
                    }

                    Enemy   current = start;
                    Enemy[] targets = new Enemy[eff.MaxTargets];
                    for (int i = 0; i < targets.Length; i++)
                    {
                        targets[i] = current;
                        Enemy next = current.GetNearestEntity(8, false,
                                                              enemy =>
                                                              enemy is Enemy &&
                                                              Array.IndexOf(targets, enemy) == -1 &&
                                                              this.Dist(enemy) <= 6) as Enemy;

                        if (next == null)
                        {
                            break;
                        }
                        else
                        {
                            current = next;
                        }
                    }

                    List <Packet> pkts = new List <Packet>();
                    for (int i = 0; i < targets.Length; i++)
                    {
                        if (targets[i] == null)
                        {
                            break;
                        }
                        Entity prev = i == 0 ? (Entity)this : targets[i - 1];
                        targets[i].Damage(this, time, eff.TotalDamage, false);
                        if (eff.ConditionEffect != null)
                        {
                            targets[i].ApplyConditionEffect(new ConditionEffect
                                {
                                    Effect     = eff.ConditionEffect.Value,
                                    DurationMS = (int)(eff.EffectDuration * 1000)
                                });
                        }
                        pkts.Add(new ShowEffectPacket
                            {
                                EffectType = EffectType.Lightning,
                                TargetId   = prev.Id,
                                Color      = new ARGB(0xffff0088),
                                PosA       = new Position
                                {
                                    X = targets[i].X,
                                    Y = targets[i].Y
                                },
                                PosB = new Position {
                                    X = 350
                                }
                            });
                    }
                    BroadcastSync(pkts, p => this.Dist(p) < 25);
                } break;

                case ActivateEffects.PoisonGrenade:
                {
                    BroadcastSync(new ShowEffectPacket
                        {
                            EffectType = EffectType.Throw,
                            Color      = new ARGB(0xffddff00),
                            TargetId   = Id,
                            PosA       = target
                        }, p => this.Dist(p) < 25);
                    Placeholder x = new Placeholder(Manager, 1500);
                    x.Move(target.X, target.Y);
                    Owner.EnterWorld(x);
                    Owner.Timers.Add(new WorldTimer(1500, (world, t) =>
                        {
                            Owner.BroadcastPacket(new ShowEffectPacket
                            {
                                EffectType = EffectType.AreaBlast,
                                Color      = new ARGB(0xffddff00),
                                TargetId   = x.Id,
                                PosA       = new Position {
                                    X = eff.Radius
                                }
                            }, null);
                            List <Enemy> enemies = new List <Enemy>();
                            Owner.AOE(target, eff.Radius, false,
                                      enemy => PoisonEnemy(enemy as Enemy, eff));
                        }));
                } break;

                case ActivateEffects.RemoveNegativeConditions:
                {
                    this.AOE(eff.Range / 2, true, player =>
                        {
                            ApplyConditionEffect(NegativeEffs);
                        });
                    BroadcastSync(new ShowEffectPacket
                        {
                            EffectType = EffectType.AreaBlast,
                            TargetId   = Id,
                            Color      = new ARGB(0xffffffff),
                            PosA       = new Position {
                                X = eff.Range / 2
                            }
                        }, p => this.Dist(p) < 25);
                } break;

                case ActivateEffects.RemoveNegativeConditionsSelf:
                {
                    ApplyConditionEffect(NegativeEffs);
                    BroadcastSync(new ShowEffectPacket
                        {
                            EffectType = EffectType.AreaBlast,
                            TargetId   = Id,
                            Color      = new ARGB(0xffffffff),
                            PosA       = new Position {
                                X = 1
                            }
                        }, p => this.Dist(p) < 25);
                } break;

                case ActivateEffects.IncrementStat:
                {
                    int idx = -1;
                    switch ((StatsType)eff.Stats)
                    {
                    case StatsType.MaximumHP: idx = 0; break;

                    case StatsType.MaximumMP: idx = 1; break;

                    case StatsType.Attack: idx = 2; break;

                    case StatsType.Defense: idx = 3; break;

                    case StatsType.Speed: idx = 4; break;

                    case StatsType.Vitality: idx = 5; break;

                    case StatsType.Wisdom: idx = 6; break;

                    case StatsType.Dexterity: idx = 7; break;
                    }
                    Stats[idx] += eff.Amount;
                    int limit = int.Parse(Manager.GameData.ObjectTypeToElement[ObjectType].Element(StatsManager.StatsIndexToName(idx)).Attribute("max").Value);
                    if (Stats[idx] > limit)
                    {
                        Stats[idx] = limit;
                    }
                    UpdateCount++;
                } break;

                case ActivateEffects.Create:     //this is a portal
                {
                    ushort objType;
                    if (!Manager.GameData.IdToObjectType.TryGetValue(eff.Id, out objType) ||
                        !Manager.GameData.Portals.ContainsKey(objType))
                    {
                        break;        // object not found, ignore
                    }
                    var entity = Entity.Resolve(Manager, objType);
                    entity.Move(X, Y);
                    int TimeoutTime = Manager.GameData.Portals[objType].TimeoutTime;

                    Owner.EnterWorld(entity);
                    World w = Manager.GetWorld(Owner.Id);                         //can't use Owner here, as it goes out of scope
                    w.Timers.Add(new WorldTimer(TimeoutTime * 1000, (world, t) => //default portal close time * 1000
                        {
                            try
                            {
                                w.LeaveWorld(entity);
                            }
                            catch     //couldn't remove portal, Owner became null. Should be fixed with RealmManager implementation
                            {
                                Console.WriteLine("Couldn't despawn portal.");
                            }
                        }));
                } break;

                case ActivateEffects.Dye:
                    if (item.Texture1 != 0)
                    {
                        Texture1 = item.Texture1;
                    }
                    if (item.Texture2 != 0)
                    {
                        Texture2 = item.Texture2;
                    }
                    SaveToCharacter();
                    break;

                case ActivateEffects.Pet:
                case ActivateEffects.UnlockPortal:
                    break;
                }
            }
            UpdateCount++;
        }
Example #33
0
 public StatsController(StatsManager statsManager)
 {
     _statsManager = statsManager;
 }
 public void SetStatsManager(StatsManager manager)
 {
     MStatsManager = manager;
 }
Example #35
0
 // Use this for initialization
 void Start()
 {
     DeathCounterText.text = StatsManager.Instance.DeathCounter.ToString();
     TimeNeededText.text   = StatsManager.GetTimeFormatted(StatsManager.Instance.TimeNeeded);
     DetailedStats.text    = buildDetailedStats();
 }
        public void RegionLoaded(Scene s)
        {
            if (!m_Enabled)
            {
                return;
            }

            if (s_processedRequestsStat == null)
            {
                s_processedRequestsStat =
                    new Stat(
                        "ProcessedFetchInventoryRequests",
                        "Number of processed fetch inventory requests",
                        "These have not necessarily yet been dispatched back to the requester.",
                        "",
                        "inventory",
                        "httpfetch",
                        StatType.Pull,
                        MeasuresOfInterest.AverageChangeOverTime,
                        stat => { stat.Value = ProcessedRequestsCount; },
                        StatVerbosity.Debug);
            }

            if (s_queuedRequestsStat == null)
            {
                s_queuedRequestsStat =
                    new Stat(
                        "QueuedFetchInventoryRequests",
                        "Number of fetch inventory requests queued for processing",
                        "",
                        "",
                        "inventory",
                        "httpfetch",
                        StatType.Pull,
                        MeasuresOfInterest.AverageChangeOverTime,
                        stat => { stat.Value = m_queue.Count; },
                        StatVerbosity.Debug);
            }

            StatsManager.RegisterStat(s_processedRequestsStat);
            StatsManager.RegisterStat(s_queuedRequestsStat);

            m_InventoryService = Scene.InventoryService;
            m_LibraryService   = Scene.LibraryService;

            // We'll reuse the same handler for all requests.
            m_webFetchHandler = new FetchInvDescHandler(m_InventoryService, m_LibraryService, Scene);

            Scene.EventManager.OnRegisterCaps += RegisterCaps;

            m_NumberScenes++;

            int nworkers = 2; // was 2

            if (ProcessQueuedRequestsAsync && m_workerThreads == null)
            {
                m_workerThreads = new Thread[nworkers];

                for (uint i = 0; i < nworkers; i++)
                {
                    m_workerThreads[i] = WorkManager.StartThread(DoInventoryRequests,
                                                                 String.Format("InventoryWorkerThread{0}", i),
                                                                 ThreadPriority.Normal,
                                                                 true,
                                                                 true,
                                                                 null,
                                                                 int.MaxValue);
                }
            }
        }
Example #37
0
        public Player(ClientProcessor psr)
            : base((short)psr.Character.ObjectType, psr.Random)
        {
            this.psr = psr;
            statsMgr = new StatsManager(this);
            switch (psr.Account.Rank)
            {
            case 0:
                Name = psr.Account.Name; break;

            case 1:
                Name = "[P] " + psr.Account.Name; break;

            case 2:
                Name = "[Helper] " + psr.Account.Name; break;

            case 3:
                Name = "[GM] " + psr.Account.Name; break;

            case 4:
                Name = "[Dev] " + psr.Account.Name; break;

            case 5:
                Name = "[HDev] " + psr.Account.Name; break;

            case 6:
                Name = "[CM] " + psr.Account.Name; break;

            case 7:
                Name = "[Founder] " + psr.Account.Name; break;
            }
            nName          = psr.Account.Name;
            AccountId      = psr.Account.AccountId;
            Level          = psr.Character.Level;
            Experience     = psr.Character.Exp;
            ExperienceGoal = GetExpGoal(psr.Character.Level);
            if (psr.Account.Rank > 2)
            {
                Stars = 75;
            }
            else if (psr.Account.Rank > 1)
            {
                Stars = 60;
            }
            else
            {
                Stars = GetStars(); //Temporary (until pub server)
            }
            Texture1    = psr.Character.Tex1;
            Texture2    = psr.Character.Tex2;
            Credits     = psr.Account.Credits;
            NameChosen  = psr.Account.NameChosen;
            CurrentFame = psr.Account.Stats.Fame;
            Fame        = psr.Character.CurrentFame;
            var state = psr.Account.Stats.ClassStates.SingleOrDefault(_ => _.ObjectType == ObjectType);

            if (state != null)
            {
                FameGoal = GetFameGoal(state.BestFame);
            }
            else
            {
                FameGoal = GetFameGoal(0);
            }
            Glowing   = false;
            Guild     = psr.Account.Guild.Name;
            GuildRank = psr.Account.Guild.Rank;
            if (psr.Character.HitPoints <= 0)
            {
                HP = psr.Character.MaxHitPoints;
                psr.Character.HitPoints = psr.Character.MaxHitPoints;
            }
            else
            {
                HP = psr.Character.HitPoints;
            }
            MP = psr.Character.MagicPoints;
            ConditionEffects = 0;
            OxygenBar        = 100;

            Decision = 0;
            combs    = new Combinations();
            price    = new Prices();

            Locked  = psr.Account.Locked != null ? psr.Account.Locked : new List <int>();
            Ignored = psr.Account.Ignored != null ? psr.Account.Ignored : new List <int>();
            using (Database dbx = new Database())
            {
                Locked  = dbx.getLockeds(this.AccountId);
                Ignored = dbx.getIgnoreds(this.AccountId);
            }

            Inventory = psr.Character.Equipment.Select(_ => _ == -1 ? null : (XmlDatas.ItemDescs.ContainsKey(_) ? XmlDatas.ItemDescs[_] : null)).ToArray();
            SlotTypes = Utils.FromCommaSepString32(XmlDatas.TypeToElement[ObjectType].Element("SlotTypes").Value);
            Stats     = new int[]
            {
                psr.Character.MaxHitPoints,
                psr.Character.MaxMagicPoints,
                psr.Character.Attack,
                psr.Character.Defense,
                psr.Character.Speed,
                psr.Character.HpRegen,
                psr.Character.MpRegen,
                psr.Character.Dexterity,
            };

            Pet = null;
        }
Example #38
0
        public int Damage(Player from, RealmTime time, int dmg, int pen, bool noDef, Projectile proj, bool deathmark = false, params ConditionEffect[] effs)
        {
            if (zeroHealth)
            {
                return(0);
            }
            if (HasConditionEffect(ConditionEffects.Invincible))
            {
                return(0);
            }
            if (!HasConditionEffect(ConditionEffects.Paused) &&
                !HasConditionEffect(ConditionEffects.Stasis))
            {
                int def = Defense;
                int res = Resilience;
                if (noDef)
                {
                    def        = 0;
                    Resilience = 0;
                }
                if (from.Specialization == "Blood" && from.AbilityActiveDurations[2] != 0)
                {
                    float totalhealth   = from.Stats[0];
                    float dmgPercentage = from.HP / totalhealth;
                    dmg = dmg + (int)(dmg * dmgPercentage);
                }
                if (from.Specialization == "Marksmanship" && from.AbilityActiveDurations[2] != 0)
                {
                    from.bowBlessing = from.bowBlessing + 5;
                    float blessing    = from.bowBlessing;
                    float dmgmodifier = blessing / 100;
                    dmg = (int)(dmg * dmgmodifier);
                }
                if (proj != null && proj.abil != null && proj.abil.Ability == ActivateAbilities.FireBall && burning)
                {
                    dmg = dmg * 3;
                }
                if (proj != null && proj.abil != null && proj.abil.Ability == ActivateAbilities.PoisonDagger)
                {
                    from.poisons.Add(new Poison(this, proj.abil));
                }
                if (proj != null && proj.abil != null && proj.abil.Ability == ActivateAbilities.ToxicBolt)
                {
                    if (Owner != null)
                    {
                        Owner.BroadcastPacket(new ShowEffectPacket
                        {
                            EffectType = EffectType.AreaBlast,
                            TargetId   = Id,
                            Color      = new ARGB(0xffddff00),
                            PosA       = new Position {
                                X = proj.abil.Radius
                            }
                        }, null);
                        Owner.AOE(new Position {
                            X = this.X, Y = this.Y
                        }, proj.abil.Radius, false,
                                  enemy =>
                        {
                            from.poisons.Add(new Poison(enemy as Enemy, proj.abil));
                        });
                    }
                }
                if (proj != null && proj.abil != null && proj.abil.Ability == ActivateAbilities.FireBlast)
                {
                    from.burns.Add(new Burn(this, proj.abil));
                }
                if (proj != null && proj.abil != null && proj.abil.Ability == ActivateAbilities.FlameVolley)
                {
                    from.burns.Add(new Burn(this, proj.abil));
                }
                if (proj != null && proj.abil != null && proj.abil.Ability == ActivateAbilities.BlastVolley)
                {
                    Owner.BroadcastPacket(new ShowEffectPacket
                    {
                        EffectType = EffectType.AreaBlast,
                        TargetId   = Id,
                        Color      = new ARGB(0xffff5500),
                        PosA       = new Position {
                            X = proj.abil.Radius
                        }
                    }, null);
                    Owner.AOE(new Position {
                        X = this.X, Y = this.Y
                    }, proj.abil.Radius, false,
                              enemy =>
                    {
                        (enemy as Enemy).Damage(from, time, proj.abil.Damage, pen, false, null);
                        if (burning)
                        {
                            from.burns.Add(new Burn(enemy as Enemy, proj.abil));
                        }
                    });
                }
                if (proj != null && proj.abil != null && proj.abil.Ability == ActivateAbilities.SkillShot)
                {
                    float elapsed     = time.TotalElapsedMs - proj.BeginTime;
                    float dmgmodifier = elapsed / 1500;
                    dmg = (int)(dmg + (dmg * dmgmodifier * 5));
                }
                if (proj != null && proj.abil != null && proj.abil.Ability == ActivateAbilities.DeathArrow)
                {
                    proj.deathhitcount++;
                    dmg = dmg * proj.deathhitcount;
                }
                int effDmg = Math.Min((int)StatsManager.GetEnemyDamage(this, dmg, pen, def, res), HP);
                if (HasConditionEffect(ConditionEffects.Invulnerable))
                {
                    effDmg = 0;
                }
                HP -= effDmg;

                if (from.DeathMarked != null)
                {
                    if (deathmark == false)
                    {
                        foreach (var i in from.DeathMarked.Keys)
                        {
                            if (i == this || i.Owner == null)
                            {
                                continue;
                            }
                            i.Damage(from, time, dmg / 10, pen, false, null, true);
                        }
                    }
                }
                ApplyConditionEffect(effs);
                if (effDmg != 0)
                {
                    Owner.BroadcastPacket(new DamagePacket
                    {
                        TargetId = Id,
                        Effects  = 0,
                        Damage   = (ushort)effDmg,
                        Killed   = HP <= 0,
                        BulletId = 0,
                        ObjectId = from != null ? from.Id : -1
                    }, null);
                }

                if (from != null)
                {
                    counter.HitBy(from, time, proj, effDmg);
                }

                if (HP <= 0 && Owner != null)
                {
                    Death(time);
                }

                UpdateCount++;
                return(effDmg);
            }
            return(0);
        }
Example #39
0
        void GenerateGravestone()
        {
            int maxed = 0;

            foreach (var i in XmlDatas.TypeToElement[ObjectType].Elements("LevelIncrease"))
            {
                int limit = int.Parse(XmlDatas.TypeToElement[ObjectType].Element(i.Value).Attribute("max").Value);
                int idx   = StatsManager.StatsNameToIndex(i.Value);
                if (Stats[idx] >= limit)
                {
                    maxed++;
                }
            }

            short objType;
            int?  time;

            switch (maxed)
            {
            case 8:
                objType = 0x0735; time = null;

                /*
                 * if (player.objType = 782) //Wizard
                 * {
                 *  objType = 0x0723; time = null;
                 * }
                 * else if (player.objType = 784) //Priest
                 * {
                 *  objType = 0x0723; time = null;
                 * }
                 * else if (player.objType = 768) //Rogue
                 * {
                 *  objType = 0x0723; time = null;
                 * }
                 * else if (player.objType = 801) //Necromancer
                 * {
                 *  objType = 0x0723; time = null;
                 * }
                 * else if (player.objType = 798) //Knight
                 * {
                 *  objType = 0x0723; time = null;
                 * }
                 * else if (player.objType = 800) //Assassin
                 * {
                 *  objType = 0x0723; time = null;
                 * }
                 * else if (player.objType = 802) //Huntress
                 * {
                 *  objType = 0x0723; time = null;
                 * }
                 * else if (player.objType = 804) //Trickster
                 * {
                 *  objType = 0x0723; time = null;
                 * }
                 * else if (player.objType = 775)  //Warrior
                 * {
                 *  objType = 0x0723; time = null;
                 * }
                 *
                 * else if (player.objType = 782)
                 * {
                 *  objType = 0x0723; time = null;
                 * }
                 * else if (player.objType = 782)
                 * {
                 *  objType = 0x0723; time = null;
                 * }
                 * else if (player.objType = 782)
                 * {
                 *  objType = 0x0723; time = null;
                 * }
                 * else if (player.objType = 782)
                 * {
                 *  objType = 0x0723; time = null;
                 * }
                 * else if (player.objType = 782)
                 * {
                 *  objType = 0x0723; time = null;
                 * }
                 */
                break;

            case 7:
                objType = 0x0734; time = null;
                break;

            case 6:
                objType = 0x072b; time = null;
                break;

            case 5:
                objType = 0x072a; time = null;
                break;

            case 4:
                objType = 0x0729; time = null;
                break;

            case 3:
                objType = 0x0728; time = null;
                break;

            case 2:
                objType = 0x0727; time = null;
                break;

            case 1:
                objType = 0x0726; time = null;
                break;

            default:
                if (Level <= 1)
                {
                    objType = 0x0723; time = 30 * 1000;
                }
                else if (Level < 20)
                {
                    objType = 0x0724; time = 60 * 1000;
                }
                else
                {
                    objType = 0x0725; time = 5 * 60 * 1000;
                }
                break;
            }
            StaticObject obj = new StaticObject(objType, time, true, time == null ? false : true, false);

            obj.Move(X, Y);
            obj.Name = this.Name;
            Owner.EnterWorld(obj);
        }
Example #40
0
 void Awake()
 {
     stats = GameObject.Find("GameManager").GetComponent <StatsManager>();
 }
Example #41
0
        public override bool HitByProjectile(Projectile projectile, RealmTime time)
        {
            if (stat)
            {
                return(false);
            }
            if (HasConditionEffect(ConditionEffects.Invincible))
            {
                return(false);
            }
            if (projectile.ProjectileOwner is Player &&
                !HasConditionEffect(ConditionEffects.Paused) &&
                !HasConditionEffect(ConditionEffects.Stasis))
            {
                var def = this.ObjectDesc.Defense;
                if (projectile.Descriptor.ArmorPiercing)
                {
                    def = 0;
                }
                int dmg = (int)StatsManager.GetDefenseDamage(this, projectile.Damage, def);
                if (!HasConditionEffect(ConditionEffects.Invulnerable))
                {
                    HP -= dmg;
                }
                ApplyConditionEffect(projectile.Descriptor.Effects);
                Owner.BroadcastPacket(new DamagePacket()
                {
                    TargetId = this.Id,
                    Effects  = projectile.ConditionEffects,
                    Damage   = (ushort)dmg,
                    Killed   = HP < 0,
                    BulletId = projectile.ProjectileId,
                    ObjectId = projectile.ProjectileOwner.Self.Id
                }, projectile.ProjectileOwner as Player);

                foreach (var i in CondBehaviors)
                {
                    if ((i.Condition & BehaviorCondition.OnHit) != 0)
                    {
                        i.Behave(BehaviorCondition.OnHit, this, time, projectile);
                    }
                }
                counter.HitBy(projectile.ProjectileOwner as Player, projectile, dmg);

                if (HP < 0)
                {
                    foreach (var i in CondBehaviors)
                    {
                        if ((i.Condition & BehaviorCondition.OnDeath) != 0)
                        {
                            i.Behave(BehaviorCondition.OnDeath, this, time, counter);
                        }
                    }
                    counter.Death();
                    if (Owner != null)
                    {
                        Owner.LeaveWorld(this);
                    }
                }
                UpdateCount++;
                return(true);
            }
            return(false);
        }
Example #42
0
        private void GenerateGravestone()
        {
            var maxed = (from i in Manager.GameData.ObjectTypeToElement[ObjectType].Elements("LevelIncrease") let xElement = Manager.GameData.ObjectTypeToElement[ObjectType].Element(i.Value)
                                                                                                                             where xElement
                                                                                                                             != null let limit = int.Parse(xElement.Attribute("max").Value) let idx = StatsManager.StatsNameToIndex(i.Value)
                                                                                                                                                                                                      where Stats[idx] >= limit select limit).Count();

            ushort objType;
            int?   time;

            switch (maxed)
            {
            case 8:
                objType = 0x0735;
                time    = null;
                break;

            case 7:
                objType = 0x0734;
                time    = null;
                break;

            case 6:
                objType = 0x072b;
                time    = null;
                break;

            case 5:
                objType = 0x072a;
                time    = null;
                break;

            case 4:
                objType = 0x0729;
                time    = null;
                break;

            case 3:
                objType = 0x0728;
                time    = null;
                break;

            case 2:
                objType = 0x0727;
                time    = null;
                break;

            case 1:
                objType = 0x0726;
                time    = null;
                break;

            default:
                if (Level <= 1)
                {
                    objType = 0x0723;
                    time    = 30 * 1000;
                }
                else if (Level < 20)
                {
                    objType = 0x0724;
                    time    = 60 * 1000;
                }
                else
                {
                    objType = 0x0725;
                    time    = 5 * 60 * 1000;
                }
                break;
            }
            var obj = new StaticObject(Manager, objType, time, true, time != null, false);

            obj.Move(X, Y);
            obj.Name = Name;
            Owner.EnterWorld(obj);
        }
Example #43
0
        public int Damage(Player from, RealmTime time, int dmg, bool noDef, params ConditionEffect[] effs)
        {
            if (stat)
            {
                return(0);
            }
            if (HasConditionEffect(ConditionEffects.Invincible))
            {
                return(0);
            }
            if (!HasConditionEffect(ConditionEffects.Paused) &&
                !HasConditionEffect(ConditionEffects.Stasis))
            {
                var def = this.ObjectDesc.Defense;
                if (noDef)
                {
                    def = 0;
                }
                dmg = (int)StatsManager.GetDefenseDamage(this, dmg, def);
                int effDmg = dmg;
                if (effDmg > HP)
                {
                    effDmg = HP;
                }
                if (!HasConditionEffect(ConditionEffects.Invulnerable))
                {
                    HP -= dmg;
                }
                ApplyConditionEffect(effs);
                Owner.BroadcastPacket(new DamagePacket()
                {
                    TargetId = this.Id,
                    Effects  = 0,
                    Damage   = (ushort)dmg,
                    Killed   = HP < 0,
                    BulletId = 0,
                    ObjectId = from.Id
                }, null);

                foreach (var i in CondBehaviors)
                {
                    if ((i.Condition & BehaviorCondition.OnHit) != 0)
                    {
                        i.Behave(BehaviorCondition.OnHit, this, time, null);
                    }
                }
                counter.HitBy(from, null, dmg);

                if (HP < 0)
                {
                    foreach (var i in CondBehaviors)
                    {
                        if ((i.Condition & BehaviorCondition.OnDeath) != 0)
                        {
                            i.Behave(BehaviorCondition.OnDeath, this, time, counter);
                        }
                    }
                    counter.Death();
                    if (Owner != null)
                    {
                        Owner.LeaveWorld(this);
                    }
                }

                UpdateCount++;
                return(effDmg);
            }
            return(0);
        }
Example #44
0
 void Awake()
 {
     stats = GameObject.Find("GameManager").GetComponent <StatsManager>();
     hook  = GameObject.Find("Player").GetComponent <GrapplingHook>();
 }
Example #45
0
 public void Awake() {
     interfaceManager = Hud.GetComponent<InterfaceManager>();
     statsManager = GetComponent<StatsManager>() ;
 }
Example #46
0
 void Awake()
 {
     stats  = GameObject.Find("GameManager").GetComponent <StatsManager>();
     quests = GameObject.Find("GameManager").GetComponent <QuestManager>();
     ui     = GameObject.Find("Canvas").GetComponent <UIManager>();
 }
Example #47
0
    void Awake()
    {
        instance = this;
        print(ot);
        if(ot)
        {
            p1_stocks = 1;
            p2_stocks = 1;
        }
        else
        {
            p1_stocks = MatchSettingsData.stock_total;
            p2_stocks = MatchSettingsData.stock_total;
        }
        countdown = MatchSettingsData.match_time + 1;
        p1Left.text = p1_stocks.ToString();
        p2Left.text = p2_stocks.ToString();

        inptmng = GameObject.Find("InputManager");
        keyinpt = inptmng.GetComponent<KeyInputManager>();
        continpt = inptmng.GetComponent<ControllerInputManager>();
        sfxmng = GameObject.Find("SoundManager").GetComponent<SFXManager>();
        if(MatchSettingsData.mstrinptmng == "Keys")
        {
            continpt.enabled = false;
            keyinpt.enabled = true;
            primaryINPT = keyinpt;
            keys = true;
        }
        else
        {
            continpt.enabled = true;
            keyinpt.enabled = false;
            primaryINPT = continpt;
            keys = false;
        }
        stats = GameObject.Find("StatsManager").GetComponent<StatsManager>();

        P1.setTag("P1");
        P1.transform.position = P1spawnPoint.position;
        p1_origin = Instantiate(P1);//clone P1
        p1_origin.enabled = false;
        p1_origin.transform.position = new Vector3(-425.5f, 245, 0);
        //p1_origin.rend.enabled = false;

        P2.setTag("P2");
        P2.transform.position = P2spawnPoint.position;
        p2_origin = Instantiate(P2);//clone P2
        p2_origin.enabled = false;
        p2_origin.transform.position = new Vector3(-431.5f, 245, 0);

        pauseMenu.SetActive(false);
        primaryINPT.lockcontrols();
    }
Example #48
0
        void Activate(RealmTime time, Item item, Position target)
        {
            MP -= item.MpCost;
            foreach (var eff in item.ActivateEffects)
            {
                switch (eff.Effect)
                {
                case ActivateEffects.BulletNova:
                {
                    var      prjDesc = item.Projectiles[0];    //Assume only one
                    Packet[] batch   = new Packet[21];
                    uint     s       = Random.CurrentSeed;
                    Random.CurrentSeed = (uint)(s * time.tickTimes);
                    for (int i = 0; i < 20; i++)
                    {
                        Projectile proj = CreateProjectile(prjDesc, item.ObjectType,
                                                           (int)statsMgr.GetAttackDamage(prjDesc.MinDamage, prjDesc.MaxDamage),
                                                           time.tickTimes, target, (float)(i * (Math.PI * 2) / 20));
                        Owner.EnterWorld(proj);
                        fames.Shoot(proj);
                        batch[i] = new ShootPacket()
                        {
                            BulletId      = proj.ProjectileId,
                            OwnerId       = Id,
                            ContainerType = item.ObjectType,
                            Position      = target,
                            Angle         = proj.Angle,
                            Damage        = (short)proj.Damage
                        };
                    }
                    Random.CurrentSeed = s;
                    batch[20]          = new ShowEffectPacket()
                    {
                        EffectType = EffectType.Trail,
                        PosA       = target,
                        TargetId   = Id,
                        Color      = new ARGB(0x000099)    //was 0xFFFF00AA
                    };
                    Owner.BroadcastPackets(batch, null);
                } break;

                case ActivateEffects.InvertNova:            //inverted spell bomb behavior. Spellbombs start on the outside and move into a center point. Good for older computers that cant do perfect spellbombs
                {
                    var      prjDesc = item.Projectiles[0]; //Assume only one
                    Packet[] batch   = new Packet[21];      //calls the shoot packet
                    uint     s       = Random.CurrentSeed;  //seeds the effects and position of effects
                    Random.CurrentSeed = (uint)(s * time.tickTimes);
                    for (int i = 0; i < 20; i++)            //this is how many bullets are shot, atm i can't get anymore or any less shots...
                    {
                        Projectile proj = CreateProjectile(prjDesc, item.ObjectType,
                                                           (int)statsMgr.GetAttackDamage(prjDesc.MinDamage, prjDesc.MaxDamage), //We can't have negative Pi?
                                                           time.tickTimes, target, (float)(i + (i * Math.PI) / 4));             //This is what divides the shots from the nova, here we can make it inverted
                        Owner.EnterWorld(proj);                                                                                 //the line above was (i * (Math.PI + 2) / 20)); //Took out Math.PI and put in the actual few numbers in pi to make it easier to use. However if you increase the range on spellbomb shots eventually the shots will become uneven because not using Math.PI; Math.PI uses EVERY infinite number, making each spellbomb 99.99999999999% accurate.
                        fames.Shoot(proj);
                        batch[i] = new ShootPacket()
                        {
                            BulletId      = proj.ProjectileId,
                            OwnerId       = Id,
                            ContainerType = item.ObjectType,
                            Position      = target,     //This plays a part of the positioning of the bullets
                            Angle         = proj.Angle, //And THIS helps angle all of the bullets correctly, but you can prolly leave it as proj.Angle
                            Damage        = (short)proj.Damage
                        };
                    }
                    Random.CurrentSeed = s;
                    batch[20]          = new ShowEffectPacket()
                    {
                        EffectType = EffectType.Trail,
                        PosA       = target,
                        TargetId   = Id,
                        Color      = new ARGB(0x00500)    //was 0xFFFF00AA
                    };
                    Owner.BroadcastPackets(batch, null);
                } break;

                case ActivateEffects.Shoot:
                {
                    ActivateShoot(time, item, target);
                } break;

                case ActivateEffects.StatBoostSelf:
                {
                    int idx = -1;
                    switch ((StatsType)eff.Stats)
                    {
                    case StatsType.MaximumHP: idx = 0; break;

                    case StatsType.MaximumMP: idx = 1; break;

                    case StatsType.Attack: idx = 2; break;

                    case StatsType.Defense: idx = 3; break;

                    case StatsType.Speed: idx = 4; break;

                    case StatsType.Vitality: idx = 5; break;

                    case StatsType.Wisdom: idx = 6; break;

                    case StatsType.Dexterity: idx = 7; break;
                    }
                    int s = eff.Amount;
                    Boost[idx] += s;
                    UpdateCount++;
                    Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) =>
                        {
                            Boost[idx] -= s;
                            UpdateCount++;
                        }));
                    Owner.BroadcastPacket(new ShowEffectPacket()
                        {
                            EffectType = EffectType.Potion,
                            TargetId   = Id,
                            Color      = new ARGB(0xffffffff)
                        }, null);
                } break;

                case ActivateEffects.StatBoostAura:
                {
                    int idx = -1;
                    switch ((StatsType)eff.Stats)
                    {
                    case StatsType.MaximumHP: idx = 0; break;

                    case StatsType.MaximumMP: idx = 1; break;

                    case StatsType.Attack: idx = 2; break;

                    case StatsType.Defense: idx = 3; break;

                    case StatsType.Speed: idx = 4; break;

                    case StatsType.Vitality: idx = 5; break;

                    case StatsType.Wisdom: idx = 6; break;

                    case StatsType.Dexterity: idx = 7; break;
                    }
                    int s = eff.Amount;
                    Behavior.AOE(Owner, this, eff.Range / 2, true, player =>
                        {
                            (player as Player).Boost[idx] += s;
                            player.UpdateCount++;
                            Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) =>
                            {
                                (player as Player).Boost[idx] -= s;
                                player.UpdateCount++;
                            }));
                        });
                    Owner.BroadcastPacket(new ShowEffectPacket()
                        {
                            EffectType = EffectType.AreaBlast,
                            TargetId   = Id,
                            Color      = new ARGB(0xffffffff), //was 0xffffffff
                            PosA       = new Position()
                            {
                                X = eff.Range / 2
                            }
                        }, null);
                } break;

                case ActivateEffects.ConditionEffectSelf:
                {
                    ApplyConditionEffect(new ConditionEffect()
                        {
                            Effect     = eff.ConditionEffect.Value,
                            DurationMS = eff.DurationMS
                        });
                    Owner.BroadcastPacket(new ShowEffectPacket()
                        {
                            EffectType = EffectType.AreaBlast,
                            TargetId   = Id,
                            Color      = new ARGB(0xffffffff), //was 0xffffffff
                            PosA       = new Position()
                            {
                                X = 1
                            }
                        }, null);
                } break;

                case ActivateEffects.ConditionEffectAura:
                {
                    Behavior.AOE(Owner, this, eff.Range / 2, true, player =>
                        {
                            player.ApplyConditionEffect(new ConditionEffect()
                            {
                                Effect     = eff.ConditionEffect.Value,
                                DurationMS = eff.DurationMS
                            });
                        });
                    uint color = 0xffffffff;
                    if (eff.ConditionEffect.Value == ConditionEffectIndex.Damaging)
                    {
                        color = 0xffff0000;
                    }
                    Owner.BroadcastPacket(new ShowEffectPacket()
                        {
                            EffectType = EffectType.AreaBlast,
                            TargetId   = Id,
                            Color      = new ARGB(color),
                            PosA       = new Position()
                            {
                                X = eff.Range / 2
                            }
                        }, null);
                } break;

                case ActivateEffects.Heal:
                {
                    List <Packet> pkts = new List <Packet>();
                    ActivateHealHp(this, eff.Amount, pkts);
                    Owner.BroadcastPackets(pkts, null);
                } break;

                case ActivateEffects.HealNova:
                {
                    List <Packet> pkts = new List <Packet>();
                    Behavior.AOE(Owner, this, eff.Range / 2, true, player =>
                        {
                            ActivateHealHp(player as Player, eff.Amount, pkts);
                        });
                    pkts.Add(new ShowEffectPacket()
                        {
                            EffectType = EffectType.AreaBlast,
                            TargetId   = Id,
                            Color      = new ARGB(0xffffffff),
                            PosA       = new Position()
                            {
                                X = eff.Range / 2
                            }
                        });
                    Owner.BroadcastPackets(pkts, null);
                } break;

                case ActivateEffects.Magic:
                {
                    List <Packet> pkts = new List <Packet>();
                    ActivateHealMp(this, eff.Amount, pkts);
                    Owner.BroadcastPackets(pkts, null);
                } break;

                case ActivateEffects.MagicNova:
                {
                    List <Packet> pkts = new List <Packet>();
                    Behavior.AOE(Owner, this, eff.Range / 2, true, player =>
                        {
                            ActivateHealMp(player as Player, eff.Amount, pkts);
                        });
                    pkts.Add(new ShowEffectPacket()
                        {
                            EffectType = EffectType.AreaBlast,
                            TargetId   = Id,
                            Color      = new ARGB(0xffffffff),
                            PosA       = new Position()
                            {
                                X = eff.Range / 2
                            }
                        });
                    Owner.BroadcastPackets(pkts, null);
                } break;

                case ActivateEffects.Teleport:
                {
                    Move(target.X, target.Y);
                    UpdateCount++;
                    Owner.BroadcastPackets(new Packet[]
                        {
                            new GotoPacket()
                            {
                                ObjectId = Id,
                                Position = new Position()
                                {
                                    X = X,
                                    Y = Y
                                }
                            },
                            new ShowEffectPacket()
                            {
                                EffectType = EffectType.Teleport,
                                TargetId   = Id,
                                PosA       = new Position()
                                {
                                    X = X,
                                    Y = Y
                                },
                                Color = new ARGB(0x000000)     //was 0xFFFFFFFF
                            }
                        }, null);
                } break;

                case ActivateEffects.VampireBlast:
                {
                    List <Packet> pkts = new List <Packet>();
                    pkts.Add(new ShowEffectPacket()
                        {
                            EffectType = EffectType.Trail,
                            TargetId   = Id,
                            PosA       = target,
                            Color      = new ARGB(0xFFFFFF) //was 0xFFFF0000
                        });
                    pkts.Add(new ShowEffectPacket()
                        {
                            EffectType = EffectType.Diffuse,
                            Color      = new ARGB(0xFFFFFF), //was 0xFFFF0000
                            TargetId   = Id,
                            PosA       = target,
                            PosB       = new Position()
                            {
                                X = target.X + eff.Radius, Y = target.Y
                            }
                        });

                    int totalDmg = 0;
                    var enemies  = new List <Enemy>();
                    Behavior.AOE(Owner, target, eff.Radius, false, enemy =>
                        {
                            enemies.Add(enemy as Enemy);
                            totalDmg += (enemy as Enemy).Damage(this, time, eff.TotalDamage, false);
                        });
                    var players = new List <Player>();
                    Behavior.AOE(Owner, this, eff.Radius, true, player =>
                        {
                            players.Add(player as Player);
                            ActivateHealHp(player as Player, totalDmg, pkts);
                        });

                    Random rand = new System.Random();
                    for (int i = 0; i < 5; i++)
                    {
                        Enemy  a = enemies[rand.Next(0, enemies.Count)];
                        Player b = players[rand.Next(0, players.Count)];
                        pkts.Add(new ShowEffectPacket()
                            {
                                EffectType = EffectType.Flow,
                                TargetId   = b.Id,
                                PosA       = new Position()
                                {
                                    X = a.X, Y = a.Y
                                },
                                Color = new ARGB(0xffffffff)     //was 0xffffffff
                            });
                    }

                    if (enemies.Count > 0)
                    {
                        Enemy  a = enemies[rand.Next(0, enemies.Count)];
                        Player b = players[rand.Next(0, players.Count)];
                        pkts.Add(new ShowEffectPacket()
                            {
                                EffectType = EffectType.Flow,
                                TargetId   = b.Id,
                                PosA       = new Position()
                                {
                                    X = a.X, Y = a.Y
                                },
                                Color = new ARGB(0Xffffffff)
                            });
                    }

                    Owner.BroadcastPackets(pkts, null);
                } break;

                case ActivateEffects.Trap:
                {
                    ARGB effColor = new ARGB(0x6600CC);         //was 0xFF9000FF
                    if (eff.Color != null)
                    {
                        effColor = new ARGB((uint)eff.Color);
                    }
                    Owner.BroadcastPacket(new ShowEffectPacket()
                        {
                            EffectType = EffectType.Throw,
                            Color      = effColor,
                            TargetId   = Id,
                            PosA       = target
                        }, null);
                    Owner.Timers.Add(new WorldTimer(1500, (world, t) =>
                        {
                            Trap trap = new Trap(
                                this,
                                eff.Radius,
                                eff.TotalDamage,
                                eff.ConditionEffect ?? ConditionEffectIndex.Slowed,
                                eff.EffectDuration);
                            trap.Move(target.X, target.Y);
                            world.EnterWorld(trap);
                        }));
                } break;

                case ActivateEffects.StasisBlast:
                {
                    List <Packet> pkts     = new List <Packet>();
                    ARGB          effColor = new ARGB(0xffffffff);
                    if (eff.Color != null)
                    {
                        effColor = new ARGB((uint)eff.Color);
                    }
                    pkts.Add(new ShowEffectPacket()
                        {
                            EffectType = EffectType.Concentrate,
                            TargetId   = Id,
                            PosA       = target,
                            PosB       = new Position()
                            {
                                X = target.X + 3, Y = target.Y
                            },
                            Color = effColor
                        });
                    Behavior.AOE(Owner, target, 3, false, enemy =>
                        {
                            if (enemy.HasConditionEffect(ConditionEffects.StasisImmune))
                            {
                                pkts.Add(new NotificationPacket()
                                {
                                    ObjectId = enemy.Id,
                                    Color    = new ARGB(0xff00ff00),  //was 0xff00ff00
                                    Text     = "Immune"
                                });
                            }
                            else if (!enemy.HasConditionEffect(ConditionEffects.Stasis))
                            {
                                enemy.ApplyConditionEffect(
                                    new ConditionEffect()
                                {
                                    Effect     = ConditionEffectIndex.Stasis,
                                    DurationMS = eff.DurationMS
                                },
                                    new ConditionEffect()
                                {
                                    Effect     = ConditionEffectIndex.Confused,
                                    DurationMS = eff.DurationMS
                                }
                                    );
                                Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) =>
                                {
                                    enemy.ApplyConditionEffect(new ConditionEffect()
                                    {
                                        Effect     = ConditionEffectIndex.StasisImmune,
                                        DurationMS = 3000
                                    }
                                                               );
                                }
                                                                ));
                                pkts.Add(new NotificationPacket()
                                {
                                    ObjectId = enemy.Id,
                                    Color    = new ARGB(0xffff0000),  //was 0xffff0000
                                    Text     = "Stasis"
                                });
                            }
                        });
                    Owner.BroadcastPackets(pkts, null);
                } break;

                case ActivateEffects.Decoy:
                {
                    var decoy = new Decoy(this, eff.DurationMS, statsMgr.GetSpeed());
                    decoy.Move(X, Y);
                    Owner.EnterWorld(decoy);
                } break;

                case ActivateEffects.MultiDecoy:
                {
                    for (var i = 0; i < eff.Amount; i++)
                    {
                        var decoy = Decoy.DecoyRandom(this, eff.DurationMS, statsMgr.GetSpeed());
                        decoy.Move(X, Y);
                        Owner.EnterWorld(decoy);
                    }
                } break;

                case ActivateEffects.Lightning:
                {
                    Enemy  start = null;
                    double angle = Math.Atan2(target.Y - Y, target.X - X);
                    double diff  = Math.PI / 3;
                    Behavior.AOE(Owner, target, 6, false, enemy =>
                        {
                            if (!(enemy is Enemy))
                            {
                                return;
                            }
                            var x = Math.Atan2(enemy.Y - Y, enemy.X - X);
                            if (Math.Abs(angle - x) < diff)
                            {
                                start = enemy as Enemy;
                                diff  = Math.Abs(angle - x);
                            }
                        });
                    if (start == null)
                    {
                        break;
                    }

                    Enemy   current = start;
                    Enemy[] targets = new Enemy[eff.MaxTargets];
                    for (int i = 0; i < targets.Length; i++)
                    {
                        targets[i] = current;
                        float dist = 8;
                        Enemy next = Behavior.GetNearestEntity(current, ref dist, false,
                                                               enemy =>
                                                               enemy is Enemy &&
                                                               Array.IndexOf(targets, enemy) == -1 &&
                                                               Behavior.Dist(this, enemy) <= 6) as Enemy;

                        if (next == null)
                        {
                            break;
                        }
                        else
                        {
                            current = next;
                        }
                    }

                    List <Packet> pkts = new List <Packet>();
                    for (int i = 0; i < targets.Length; i++)
                    {
                        if (targets[i] == null)
                        {
                            break;
                        }
                        Entity prev = i == 0 ? (Entity)this : targets[i - 1];
                        targets[i].Damage(this, time, eff.TotalDamage, false);
                        if (eff.ConditionEffect != null)
                        {
                            targets[i].ApplyConditionEffect(new ConditionEffect()
                                {
                                    Effect     = eff.ConditionEffect.Value,
                                    DurationMS = (int)(eff.EffectDuration * 1000)
                                });
                        }
                        ARGB shotColor = new ARGB(0x000000);         //was 0xffff0088
                        if (eff.Color != null)
                        {
                            shotColor = new ARGB((uint)eff.Color);
                        }
                        pkts.Add(new ShowEffectPacket()
                            {
                                EffectType = EffectType.Lightning,
                                TargetId   = prev.Id,
                                Color      = shotColor,
                                PosA       = new Position()
                                {
                                    X = targets[i].X,
                                    Y = targets[i].Y
                                },
                                PosB = new Position()
                                {
                                    X = 350
                                }
                            });
                    }
                    Owner.BroadcastPackets(pkts, null);
                } break;

                case ActivateEffects.PoisonGrenade:
                {
                    try
                    {
                        Owner.BroadcastPacket(new ShowEffectPacket()
                            {
                                EffectType = EffectType.Throw,
                                Color      = new ARGB(0x006600), //was 0xffddff00
                                TargetId   = Id,
                                PosA       = target
                            }, null);
                        Placeholder x = new Placeholder(1500);
                        x.Move(target.X, target.Y);
                        Owner.EnterWorld(x);
                        Owner.Timers.Add(new WorldTimer(1500, (world, t) =>
                            {
                                try
                                {
                                    Owner.BroadcastPacket(new ShowEffectPacket()
                                    {
                                        EffectType = EffectType.AreaBlast,
                                        Color      = new ARGB(0xffddff00),
                                        TargetId   = x.Id,
                                        PosA       = new Position()
                                        {
                                            X = eff.Radius
                                        }
                                    }, null);
                                }
                                catch { Console.ForegroundColor = ConsoleColor.DarkRed;
                                        Console.Out.WriteLine("Crash halted - Nobody likes death...");
                                        Console.ForegroundColor = ConsoleColor.White; }
                                List <Enemy> enemies = new List <Enemy>();
                                Behavior.AOE(world, target, eff.Radius, false,
                                             enemy => PoisonEnemy(enemy as Enemy, eff));
                            }));
                    }
                    catch
                    {
                        Console.ForegroundColor = ConsoleColor.DarkBlue;
                        Console.Out.WriteLine("Crash halted - Poison grenade??");
                        Console.ForegroundColor = ConsoleColor.White;
                    }
                } break;

                case ActivateEffects.RemoveNegativeConditions:
                {
                    Behavior.AOE(Owner, this, eff.Range / 2, true, player =>
                        {
                            ApplyConditionEffect(NegativeEffs);
                        });
                    Owner.BroadcastPacket(new ShowEffectPacket()
                        {
                            EffectType = EffectType.AreaBlast,
                            TargetId   = Id,
                            Color      = new ARGB(0xffffffff),
                            PosA       = new Position()
                            {
                                X = eff.Range / 2
                            }
                        }, null);
                } break;

                case ActivateEffects.RemoveNegativeConditionsSelf:
                {
                    ApplyConditionEffect(NegativeEffs);
                    Owner.BroadcastPacket(new ShowEffectPacket()
                        {
                            EffectType = EffectType.AreaBlast,
                            TargetId   = Id,
                            Color      = new ARGB(0xffffffff),
                            PosA       = new Position()
                            {
                                X = 1
                            }
                        }, null);
                } break;

                case ActivateEffects.IncrementStat:
                {
                    int idx = -1;
                    switch ((StatsType)eff.Stats)
                    {
                    case StatsType.MaximumHP: idx = 0; break;

                    case StatsType.MaximumMP: idx = 1; break;

                    case StatsType.Attack: idx = 2; break;

                    case StatsType.Defense: idx = 3; break;

                    case StatsType.Speed: idx = 4; break;

                    case StatsType.Vitality: idx = 5; break;

                    case StatsType.Wisdom: idx = 6; break;

                    case StatsType.Dexterity: idx = 7; break;
                    }
                    Stats[idx] += eff.Amount;
                    int limit = int.Parse(XmlDatas.TypeToElement[ObjectType].Element(StatsManager.StatsIndexToName(idx)).Attribute("max").Value);
                    if (Stats[idx] > limit)
                    {
                        Stats[idx] = limit;
                    }
                    UpdateCount++;
                } break;

                case ActivateEffects.Create:     //this is a portal
                {
                    short objType;
                    if (!XmlDatas.IdToType.TryGetValue(eff.Id, out objType) ||
                        !XmlDatas.PortalDescs.ContainsKey(objType))
                    {
                        break;        // object not found, ignore
                    }
                    var entity = Entity.Resolve(objType);
                    entity.Move(X, Y);
                    int    TimeoutTime = XmlDatas.PortalDescs[objType].TimeoutTime;
                    string DungName    = XmlDatas.PortalDescs[objType].DungeonName;

                    Owner.EnterWorld(entity);
                    ARGB c;
                    c.A = 0;
                    c.B = 91;
                    c.R = 233;
                    c.G = 176;
                    psr.SendPacket(new NotificationPacket()
                        {
                            Color    = c,
                            Text     = DungName + " opened by " + psr.Account.Name,
                            ObjectId = psr.Player.Id
                        });
                    World w = RealmManager.GetWorld(Owner.Id);     //can't use Owner here, as it goes out of scope
                    w.BroadcastPacket(new TextPacket()
                        {
                            BubbleTime = 0,
                            Stars      = -1,
                            Name       = "",
                            Text       = DungName + " opened by " + psr.Account.Name
                        }, null);
                    w.Timers.Add(new WorldTimer(TimeoutTime * 1000, (world, t) =>     //default portal close time * 1000
                        {
                            try
                            {
                                w.LeaveWorld(entity);
                            }
                            catch //couldn't remove portal, Owner became null. Should be fixed with RealmManager implementation
                            {
                                Console.WriteLine("Couldn't despawn portal.");
                            }
                        }));
                } break;

                case ActivateEffects.Dye:
                {
                    if (item.Texture1 != 0)
                    {
                        this.Texture1 = item.Texture1;
                    }
                    if (item.Texture2 != 0)
                    {
                        this.Texture2 = item.Texture2;
                    }
                    this.SaveToCharacter();
                } break;

                case ActivateEffects.ShurikenAbility:
                {
                    World w = RealmManager.GetWorld(Owner.Id);
                    ApplyConditionEffect(new ConditionEffect()
                        {
                            Effect     = ConditionEffectIndex.Speedy,
                            DurationMS = eff.DurationMS
                        });
                    w.Timers.Add(new WorldTimer(eff.DurationMS * 1000, (world, t) =>
                        {
                            try
                            {
                                ActivateShoot(time, item, target);
                            }
                            catch
                            {
                            }
                        }));
                } break;

                case ActivateEffects.TomeDamage:
                {
                    List <Packet> pkts = new List <Packet>();
                    Behavior.AOE(Owner, this, eff.Range / 2, false, enemy =>
                        {
                            (enemy as Enemy).Damage(this, time, (int)this.statsMgr.GetAttackDamage(eff.TotalDamage, eff.TotalDamage), false, new ConditionEffect[0]);
                        });
                    pkts.Add(new ShowEffectPacket()
                        {
                            EffectType = EffectType.AreaBlast,
                            TargetId   = Id,
                            Color      = new ARGB(0xFF00FF00),
                            PosA       = new Position()
                            {
                                X = eff.Range / 2
                            }
                        });
                    Owner.BroadcastPackets(pkts, null);
                } break;

                case ActivateEffects.Mushroom:
                {
                    World w = RealmManager.GetWorld(Owner.Id);
                    Size = eff.Amount;
                    UpdateCount++;
                    w.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) =>
                        {
                            try
                            {
                                Size = 100;
                                UpdateCount++;
                            }
                            catch { }
                        }));
                } break;

                /*case ActivateEffects.PermaPet: //petcode
                 *  {
                 *      psr.Character.Pet = XmlDatas.IdToType[eff.ObjectId];
                 *      GivePet(XmlDatas.IdToType[eff.ObjectId]);
                 *      UpdateCount++;
                 *  } break;
                 * case ActivateEffects.Pet: //Drakes*/
                case ActivateEffects.UnlockPortal:
                    break;
                }
            }
            UpdateCount++;
        }
Example #49
0
 // Use this for initialization
 void Start()
 {
     m_manager = GameObject.FindGameObjectWithTag("StatsManager").GetComponent <StatsManager>();
 }
Example #50
0
        public Player(ClientProcessor psr)
            : base((short) psr.Character.ObjectType, psr.Random)
        {
            this.psr = psr;
            statsMgr = new StatsManager(this);
            nName = psr.Account.Name;
            AccountId = psr.Account.AccountId;
            if (psr.Account.Tag != "")
            {
                Name = "[" + psr.Account.Tag + "] " + psr.Account.Name;
            }
            else
            {
                Name = psr.Account.Name;
            }
            Level = psr.Character.Level;
            Experience = psr.Character.Exp;
            ExperienceGoal = GetExpGoal(psr.Character.Level);
            if (psr.Account.Name == "Lucifer" || psr.Account.Name == "Luciferus" || psr.Account.Name == "Amaymon")
                Stars = 666;
            else if (psr.Account.Rank > 2)
                Stars = 100;
            else if (psr.Account.Rank > 1)
                Stars = 95;
            else
                Stars = GetStars(); //Temporary (until pub server)
            Texture1 = psr.Character.Tex1;
            Texture2 = psr.Character.Tex2;
            Credits = psr.Account.Credits;
            zTokens = psr.Account.zTokens;
            NameChosen = psr.Account.NameChosen;
            CurrentFame = psr.Account.Stats.Fame;
            Fame = psr.Character.CurrentFame;
            var state = psr.Account.Stats.ClassStates.SingleOrDefault(_ => _.ObjectType == ObjectType);
            FameGoal = GetFameGoal(state != null ? state.BestFame : 0);
            Glowing = false;
            Guild = psr.Account.Guild.Name;
            GuildRank = psr.Account.Guild.Rank;
            if (psr.Character.HitPoints <= 0)
            {
                HP = psr.Character.MaxHitPoints;
                psr.Character.HitPoints = psr.Character.MaxHitPoints;
            }
            else
                HP = psr.Character.HitPoints;
            MP = psr.Character.MagicPoints;
            ConditionEffects = 0;
            OxygenBar = 100;

            Decision = 0;
            price = new Prices();

            Locked = psr.Account.Locked ?? new List<int>();
            Ignored = psr.Account.Ignored ?? new List<int>();
            try
            {
                using (var dbx = new Database())
                {
                    Locked = dbx.GetLockeds(AccountId);
                    Ignored = dbx.GetIgnoreds(AccountId);

                    dbx.Dispose();
                }
            }
            catch
            {
            }

            Inventory =
                psr.Character.Equipment.Select(
                    _ => _ == -1 ? null : (XmlDatas.ItemDescs.ContainsKey(_) ? XmlDatas.ItemDescs[_] : null)).ToArray();
            SlotTypes = Utils.FromCommaSepString32(XmlDatas.TypeToElement[ObjectType].Element("SlotTypes").Value);
            Stats = new[]
            {
                psr.Character.MaxHitPoints,
                psr.Character.MaxMagicPoints,
                psr.Character.Attack,
                psr.Character.Defense,
                psr.Character.Speed,
                psr.Character.HpRegen,
                psr.Character.MpRegen,
                psr.Character.Dexterity
            };

            Pet = null;
        }
Example #51
0
 void Start()
 {
     sound = GetComponent <AudioSource>();
     stats = GameObject.Find("GameManager").GetComponent <StatsManager>();
 }
Example #52
0
        private static void Main2(string[] args)
        {
            if (args.Length != 1)
            {
                throw new InvalidUserParamsException(
                    "RandoopBare takes exactly one argument but was "
                    + "given the following arguments:"
                    + System.Environment.NewLine
                    + Util.PrintArray(args));;
            }

            // Parse XML file with generation parameters.
            String configFileName = Common.ConfigFileName.Parse(args[0]);
            RandoopConfiguration config = LoadConfigFile(configFileName);

            // Set the random number generator.
            if (config.randomSource == RandomSource.SystemRandom)
            {
                Console.WriteLine("Randoom seed = " + config.randomseed);
                Common.SystemRandom random = new Common.SystemRandom();
                random.Init(config.randomseed);
                Common.Enviroment.Random = random;
            }
            else
            {
                Util.Assert(config.randomSource == RandomSource.Crypto);
                Console.WriteLine("Randoom seed = new System.Security.Cryptography.RNGCryptoServiceProvider()");
                Common.Enviroment.Random = new CryptoRandom();
            }

            if (!Directory.Exists(config.outputdir))
                throw new Common.RandoopBareExceptions.InvalidUserParamsException("output directory does not exist: "
                    + config.outputdir);

            Collection<Assembly> assemblies = Common.Misc.LoadAssemblies(config.assemblies);

            ////[email protected] for substituting MessageBox.Show() - start
            ////Instrument instrumentor = new Instrument();
            //foreach (FileName asm in config.assemblies)
            //{
            //    Instrument.MethodInstrument(asm.fileName, "System.Windows.Forms.MessageBox::Show", "System.Console.Writeline");
            //}            
            ////[email protected] for substituting MessageBox.Show() - end

            IReflectionFilter filter1 = new VisibilityFilter(config);
            ConfigFilesFilter filter2 = new ConfigFilesFilter(config);

            Console.WriteLine("========== REFLECTION PATTERNS:");
            filter2.PrintFilter(Console.Out);

            IReflectionFilter filter = new ComposableFilter(filter1, filter2);

            Collection<Type> typesToExplore = ReflectionUtils.GetExplorableTypes(assemblies);

            PlanManager planManager = new PlanManager(config);
            planManager.builderPlans.AddEnumConstantsToPlanDB(typesToExplore);
            planManager.builderPlans.AddConstantsToTDB(config);

            Console.WriteLine("========== INITIAL PRIMITIVE VALUES:");
            planManager.builderPlans.PrintPrimitives(Console.Out);

            StatsManager stats = new StatsManager(config);

            Console.WriteLine("Analyzing assembly.");

            ActionSet actions = null;
            try
            {
                actions = new ActionSet(typesToExplore, filter);
            }
            catch (EmpytActionSetException)
            {
                string msg = "After filtering based on configuration files, no remaining methods or constructors to explore.";
                throw new Common.RandoopBareExceptions.InvalidUserParamsException(msg);
            }

            Console.WriteLine();
            Console.WriteLine("Generating tests.");

            RandomExplorer explorer =
                new RandomExplorer(typesToExplore, filter, true, config.randomseed, config.arraymaxsize, stats, actions);
            ITimer t = new Timer(config.timelimit);
            try
            {
                explorer.Explore(t, planManager, config.methodweighing, config.forbidnull, true, config.fairOpt);
            }
            catch (Exception e)
            {
                Console.WriteLine("Explorer raised exception {0}", e.ToString());
            }

            //Mono.Cecil.Cil.
        }
        private bool CheckLevelUp()
        {
            if (Experience - GetLevelExp(Level) >= ExperienceGoal && Level < 20)
            {
                Level++;
                ExperienceGoal = GetExpGoal(Level);
                foreach (var i in Manager.GameData.ObjectTypeToElement[ObjectType].Elements("LevelIncrease"))
                {
                    var rand     = new Random();
                    var min      = int.Parse(i.Attribute("min").Value);
                    var max      = int.Parse(i.Attribute("max").Value) + 1;
                    var xElement = Manager.GameData.ObjectTypeToElement[ObjectType].Element(i.Value);
                    if (xElement == null)
                    {
                        continue;
                    }
                    var limit =
                        int.Parse(
                            xElement.Attribute("max").Value);
                    var idx = StatsManager.StatsNameToIndex(i.Value);
                    Stats[idx] += rand.Next(min, max);
                    if (Stats[idx] > limit)
                    {
                        Stats[idx] = limit;
                    }
                }
                HP = Stats[0] + Boost[0];
                Mp = Stats[1] + Boost[1];

                UpdateCount++;

                if (Level == 10)
                {
                    foreach (var i in Owner.Players.Values)
                    {
                        i.SendInfo(Name + " achieved level 10");
                    }
                    XpBoosted       = false;
                    XpBoostTimeLeft = 0;
                }

                else if (Level == 20)
                {
                    foreach (var i in Owner.Players.Values)
                    {
                        i.SendInfo(Name + " Is now maxed level!");
                    }
                    XpBoosted       = false;
                    XpBoostTimeLeft = 0;
                }

                else if (Level == 30)
                {
                    foreach (var i in Owner.Players.Values)
                    {
                        i.SendInfo(Name + " achieved level 30");
                    }
                    XpBoosted       = false;
                    XpBoostTimeLeft = 0;
                }

                else if (Level == 40)
                {
                    foreach (var i in Owner.Players.Values)
                    {
                        i.SendInfo(Name + " achieved level 40");
                    }
                    XpBoosted       = false;
                    XpBoostTimeLeft = 0;
                }

                else if (Level == 50)
                {
                    foreach (var i in Owner.Players.Values)
                    {
                        i.SendInfo(Name + " achieved level 50");
                    }
                    XpBoosted       = false;
                    XpBoostTimeLeft = 0;
                }

                else if (Level == 60)
                {
                    foreach (var i in Owner.Players.Values)
                    {
                        i.SendInfo(Name + " achieved level 60");
                    }
                    XpBoosted       = false;
                    XpBoostTimeLeft = 0;
                }

                else if (Level == 70)
                {
                    foreach (var i in Owner.Players.Values)
                    {
                        i.SendInfo(Name + " achieved level 70");
                    }
                    XpBoosted       = false;
                    XpBoostTimeLeft = 0;
                }

                else if (Level == 80)
                {
                    foreach (var i in Owner.Players.Values)
                    {
                        i.SendInfo(Name + " achieved level 80");
                    }
                    XpBoosted       = false;
                    XpBoostTimeLeft = 0;
                }

                else if (Level == 90)
                {
                    foreach (var i in Owner.Players.Values)
                    {
                        i.SendInfo(Name + " achieved level 90");
                    }
                    XpBoosted       = false;
                    XpBoostTimeLeft = 0;
                }

                else if (Level == 100)
                {
                    foreach (var i in Owner.Players.Values)
                    {
                        i.SendInfo(Name + " achieved level 100");
                    }
                    XpBoosted       = false;
                    XpBoostTimeLeft = 0;
                }

                else if (Level == 100)
                {
                    foreach (var i in Owner.Players.Values)
                    {
                        i.SendInfo(Name + " achieved Super Saiyan God");
                    }
                    XpBoosted       = false;
                    XpBoostTimeLeft = 0;
                }
                Quest = null;
                return(true);
            }
            CalculateFame();
            return(false);
        }
Example #54
0
    public virtual void Damage(AttackDetails attackDetails)
    {
        StatsManager.TakeDamage(attackDetails);

        LastDamageDirection = attackDetails.position.x > AliveGameObject.transform.position.x ? -1 : 1;
    }
    void Awake()
    {
        inputManager = GetComponent<InputManager>();
        guiManager = GetComponent<GUIManager>();
        appManager = GetComponent<AppManager>();
        statsManager = GetComponent<StatsManager>();

        gameCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();
        gameCameraInitialPosition = gameCamera.transform.position;
        gameCameraTargetPosition = gameCameraInitialPosition;

        Instantiate(character, new Vector3(0, 16, 0), Quaternion.identity);
        AssignCharacter();
    }
Example #56
0
    // Use this for initialization
    void Start()
    {
        DontDestroyOnLoad(this);

        serviceManager = ServiceManager.Instance;

        if (serviceManager.ContainsService(ServiceType.EventManager))
        {
            Debug.Log("GameManager.Start being called a second time.");
        }
        else
        {
            EventManager eventManager = new EventManager();
            serviceManager.AddService(ServiceType.EventManager, eventManager);

            GameObject input = (GameObject)Instantiate(inputManager);
            input.transform.parent = this.transform;
            serviceManager.AddService(ServiceType.InputManager, input.GetComponent<InputManager>());

            GameObject hudObject = (GameObject)Instantiate(hud);
            hudObject.transform.parent = this.transform;

            StatsManager statsManager = new StatsManager();
            serviceManager.AddService(ServiceType.StatsManager, statsManager);
            //TODO: the stats manager shouldn't be responsible for initializing the stats
            statsManager.Initialize();

            GameObject collectibles = (GameObject)Instantiate (collectibleFactory);
            collectibles.transform.parent = this.transform;
            serviceManager.AddService(ServiceType.CollectibleFactory, collectibles.GetComponent<CollectibleFactory>());

            GameObject levels = (GameObject)Instantiate(levelManager);
            levels.transform.parent = this.transform;
            LevelManager levelManagerScript = levels.GetComponent<LevelManager>();
            serviceManager.AddService(ServiceType.LevelManager, levelManagerScript);

            InitializeLevels(levelManagerScript);
            //statsManager.SetWeight(1600f);
            levelManagerScript.TransitionToLevel(1);
        }
    }
    StatsManager statistics; // referenja do menedzera statystyk



    private void Start()
    {
        //pobranie rereferencji
        statistics = FindObjectOfType <StatsManager>();
        playerRef  = FindObjectOfType <Player>();
    }