Inheritance: MonoBehaviour
 public GroundOnTimeAppliedEffect(int id, Effect effect, int nbTurn, Character caster)
 {
     _id = id;
     _effect = effect;
     _nbTurn = nbTurn;
     _caster = caster;
 }
Example #2
0
 public override void apply(Character character)
 {
     if(Engine.MarioControl)
         character.XAcc -= accelerationSpeed * (character is Player ? character.Jumping ? 8 : 8 : 1 * _speedMod);
     else
         character.XAcc -= accelerationSpeed * (character is Player ? character.Jumping ? 6 : 6 : 1.5);
 }
Example #3
0
        public virtual void ModifyActionList(Character character, ConsideredActions alreadyConsidered, IList<string> log)
        {
            if (BaseDueDate != null && BaseDueDate == 0)
            {
                return;
            }
            IEnumerable<IBook> readableBooks = character.ReadableBooks;
            foreach (Ability ability in _abilities)
            {
                // Handle Reading
                CharacterAbilityBase charAbility = character.GetAbility(ability);
                var topicalBooks = readableBooks.Where(b => b.Topic == ability);
                HandleReading(character, alreadyConsidered, topicalBooks);

                // Handle Practice
                if (!MagicArts.IsArt(ability))
                {
                    HandlePractice(character, alreadyConsidered, log, ability);
                }
                else if (character.GetType() == typeof(Magus))
                {
                    Magus mage = (Magus)character;
                    HandleVisUse(mage, charAbility, alreadyConsidered, log);
                }

                // TODO: Learning By Training
                // TODO: Learning by Teaching
            }
        }
Example #4
0
    override public void CharacterEnter(Character p) {
      if (p == null) return;

      base.CharacterEnter(p);
      p.EnterArea(Areas.Grabbable);
      p.grab = this;
    }
        /// <summary>
        /// Add modifiers.
        /// </summary>
        /// <param name="stage">
        /// The stage during character update this is called.
        /// </param>
        /// <param name="addModifier">
        /// Add modifiers by calling this method.
        /// </param>
        /// <param name="character">
        /// The character to add modifiers for.
        /// </param>
        protected override void AddModifiers(CharacterUpdateStage stage, Action<Modifier> addModifier, Character character)
        {
            base.AddModifiers(stage, addModifier, character);

            addModifier(new Modifier(character[ScoreType.Speed], character[MovementMode], character[ScoreType.Speed].Total));
            addModifier(new Modifier(this, character[MovementMode], 0, string.Format("see {0}", Name)));
        }
Example #6
0
 public Player(string type)
 {
     switch (type.ToLower())
     {
         case "hero":
             wrestler = new Hero();
             break;
         case "luchador":
             wrestler = new Luchador();
             break;
         case "technician":
             wrestler = new Technician();
             break;
         case "giant":
             wrestler = new Giant();
             break;
         case "brawler":
             wrestler = new Brawler();
             break;
         default:
             wrestler = new Hero();
             break;
     }
     hand = new int[5];
     currHealth = wrestler.health;
     currDeck = wrestler.getDeck();
     hand = wrestler.hand;
     handCounter = 0;
     tapdown = false;
     stance = 0;
     turn = false;
     turnCounter = wrestler.turnCounter;
     countering = false;
 }
Example #7
0
 // Use this for initialization
 void Start()
 {
     owner = GetComponentInParent<Character>();
     playerHit = Resources.Load<ParticleSystem>("Particles/Prefabs/OnHit/FX_BloodHit_Player");
     enemyHit = Resources.Load<ParticleSystem>("Particles/Prefabs/OnHit/FX_BloodHit_EnemySlow");
     envHit = Resources.Load<ParticleSystem>("Particles/Prefabs/OnHit/FX_EnvHit");
 }
        public static void Send(Character character, InventoryEntries inventoryEntry)
        {
            PacketWriter packetWriter = new PacketWriter();

            packetWriter.PushByte(0xdf);
            packetWriter.PushByte(0xdf);
            packetWriter.PushShort(0xa);
            packetWriter.PushShort(1);
            packetWriter.PushShort(0);
            packetWriter.PushInt(3086);
            packetWriter.PushInt(character.Id);
            packetWriter.PushInt(0x35505644);
            packetWriter.PushInt(50000);
            packetWriter.PushInt(character.Id);
            packetWriter.PushByte(0);
            packetWriter.PushInt(inventoryEntry.Item.LowID);
            packetWriter.PushInt(inventoryEntry.Item.HighID);
            packetWriter.PushInt(inventoryEntry.Item.Quality);
            packetWriter.PushInt(1); // Unknown
            packetWriter.PushInt(3); // Consume??
            packetWriter.PushInt(inventoryEntry.Container);
            packetWriter.PushInt(inventoryEntry.Placement);
            packetWriter.PushInt(0); // Unknown
            packetWriter.PushInt(0); // Unknown

            byte[] packet = packetWriter.Finish();
            character.Client.SendCompressed(packet);
        }
        public void TestJsonSerialization(Character character)
        {
            JsonCharacterSerializer characterSerializer;
            Character newCharacter;
            string json;

            characterSerializer = new JsonCharacterSerializer();
            json = characterSerializer.Serialize(character);
            newCharacter = characterSerializer.Deserialize(json);

            Assert.That(newCharacter, Is.EqualTo(character), "Characters differ");
            Assert.That(newCharacter.GetHeldItem<Item>(Hand.Main), Is.EqualTo(character.GetHeldItem<Item>(Hand.Main)),
                "Main hands differ");
            Assert.That(newCharacter.GetHeldItem<Item>(Hand.Off), Is.EqualTo(character.GetHeldItem<Item>(Hand.Off)),
                "Main hands differ");
            Assert.That(
                Array.ConvertAll((Slot[])Enum.GetValues(typeof(Slot)), x => newCharacter.GetEquippedItem<Item>(x)),
                Is.EquivalentTo(Array.ConvertAll((Slot[])Enum.GetValues(typeof(Slot)), character.GetEquippedItem<Item>)),
                "Equipped items differ");
            Assert.That(
                newCharacter.Gear.OrderBy(x => x.Name),
                Is.EquivalentTo(character.Gear.OrderBy(x => x.Name)),
                "Carried items differ");
            Assert.That(
                newCharacter.Levels.OrderBy(x => x.Number),
                Is.EquivalentTo(character.Levels.OrderBy(x => x.Number)),
                "Levels differ");
        }
Example #10
0
    public override void HandleEnemyHpChange(Character target)
    {
        if (owner.IsDizzy)
            return;

        float percent = Percent / 100f;

        if (isAdd == false)
        {
            if (CanAtk(percent, target))
            {
                ChangeAttri(owner);
                PlaySelfEffect();
                AddTbuff(owner);
                isAdd = true;
                PushTskill();
            }
        }
        else
        {
            if (GetTarget() == null)
            {
                EndAttri();
            }
        }
    }
Example #11
0
	private bool CheckVolume(Character target)
	{
		float min, max;
		min = size * minSizeLimit;
		max = size * maxSizeLimit;
		return min <= target.size && target.size < max;
	}
	protected Character AIRayCast (Character targetCharacter){
		SorcererAI ai = gameObject.GetComponent<SorcererAI> ();
		if (ai != null && ai.enabled == true) {
			return ai.checkNearestEnemy();
		}
		return targetCharacter;
	}
Example #13
0
//	public void FireMulti(Character target){
//		curTarget = target;
//		Transform house = transform.GetChild (0);
//		house.gameObject.GetComponent<Renderer>().sortingOrder = 4;
//		foreach(Character chara in EnemySpawnManager._instance.enemyList){
//			if(Vector3.Distance(chara.GetPos(),curTarget.GetPos()) <= explosionRange){
//				curTargetList.Add(chara);
//			}
//		}
//		distanceToTarget = Vector3.Distance (this.transform.position, target.GetPos());
//		StartCoroutine (Shoot (target));
//	}

	IEnumerator Shoot(Character target){
		while (move) {
			if(target != null){
				Vector3 targetPos = target.GetPos();
				this.transform.LookAt(targetPos);
				float currentDist = Vector3.Distance(this.transform.position, target.GetPos());
				if(currentDist < minDistance){
					move = false;
					if(node.GetPosion && isAntennaFire == false){
						OnDOTEffect();
					}
					OnHited();
				}
				this.transform.Translate(Vector3.forward*Mathf.Min(speed * Time.deltaTime,currentDist));
				yield return null;
			}
			else{
				move = false;
				if(parent1 != null){
					parent1 = null;
					BulletPool.instance.Push(this.gameObject);
				}
				else if(antennaParent != null){
					antennaParent = null;
					AtennaEffectPool.instance.Push(this.gameObject);
				}
				else 
					Destroy(this.gameObject);
			}
		}
	}
Example #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CharacterMonitor"/> class.
 /// </summary>
 /// <param name="character">The character.</param>
 public CharacterMonitor(Character character)
     : this()
 {
     Header.SetCharacter(character);
     Body.SetCharacter(character);
     Footer.SetCharacter(character);
 }
 public void Use(UseActionEnum actionEnum, Character.MyCharacter user)
 {
     switch(actionEnum)
     {
         case UseActionEnum.Manipulate:
             if (!m_buttonPanel.IsWorking)
                 return;
             if (!m_buttonPanel.AnyoneCanUse && !m_buttonPanel.HasLocalPlayerAccess())
             {
                 MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
                 return;
             }
             m_buttonPanel.Toolbar.UpdateItem(m_index);
             m_buttonPanel.Toolbar.ActivateItemAtIndex(m_index);
             m_buttonPanel.PressButton(m_index);
             break;
         case UseActionEnum.OpenTerminal:
             if (!m_buttonPanel.HasLocalPlayerAccess())
                 return;
             MyToolbarComponent.CurrentToolbar = m_buttonPanel.Toolbar;
             MyGuiScreenBase screen = MyGuiScreenCubeBuilder.Static;
             if (screen == null)
                 screen = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.ToolbarConfigScreen, 0, m_buttonPanel);
             MyToolbarComponent.AutoUpdate = false;
             screen.Closed += (source) => MyToolbarComponent.AutoUpdate = true;
             MyGuiSandbox.AddScreen(screen);
             break;
         default:
             break;
     }
 }
    public bool basicAttack(Character target)
    {
        if(currentActionPoints > 1)
        {
            if(attackCooldown)
            {
                return true;
            }
            bool inRange = false;
            List<PathTile> tilesInRange = new List<PathTile>();
            tilesInRange.Add(target.start);
            for(int i = 0; i < range; i++)
            {
                List<PathTile> tempTilesInRange = new List<PathTile>();
                foreach(PathTile pt in tilesInRange)
                {
                    tempTilesInRange.AddRange(pt.connections);
                }
                tilesInRange.AddRange(tempTilesInRange);
            }

            foreach(PathTile pt in tilesInRange)
            {
                if(start == pt)
                {
                    inRange = true;
                    break;
                }
                //This is a test that can be used to see what tiles are in range of an attack
                //The break above must be commented out to run this debug, as well as highlight tiles
                //pt.gameObject.GetComponent<MeshRenderer>().material.color = Color.red;
            }

            if(inRange)
            {
                Debug.Log(this.gameObject.name + " attacks " + target.gameObject.name);
                int damageDealt = (int)Mathf.Round(this.strength-(this.strength * ((target.endurance * .06f) / (1 + (target.endurance * 0.06f)))));
                if(damageDealt <=0)
                    damageDealt = 1;
                target.health -= damageDealt;
                currentActionPoints -= 2;
                if(currentActionPoints <= 0)
                    active = false;
                StartCoroutine(DamageTextScroll(damageDealt, target));
            }
            //else
            //{
                //Move until in range and call attack again
                //Move();
                //basicAttack(target);
            //}
            return true;
        }
        else
        {
            Debug.Log ("Not enough action points to attack.");
            return false;

        }
    }
    public CharacterStatsController(Character character)
    {
        //_character = character;
        _sphereMaterial = character.PhysicsController.Capsule.GetComponent<MeshRenderer>().sharedMaterial;

        UpdateHealthColor();
    }
Example #18
0
 public static void OpenLocationGuide(Character target, uint menu)
 {
     SMSG_NPCASKLOCATION spkt = new SMSG_NPCASKLOCATION();
     spkt.Script = menu;
     spkt.SessionId = target.id;
     target.client.Send((byte[])spkt);
 }
Example #19
0
 public static void OpenMenu(Character target, MapObject source, uint dialogScript, DialogType type, params DialogType[] icons)
 {
     byte[] dialogs = new byte[icons.Length];
     for (int i = 0; i < icons.Length; i++)
         dialogs[i] = (byte)icons[i];
     OpenMenu(target, source, dialogScript, type, dialogs);
 }
Example #20
0
    public void showSkill30AAttackEft(Character c)
    {
        if(c is Caiera)
        {
            Caiera caiera = c as Caiera;
            caiera.showSkill30AAttackEftCallback -= showSkill30AAttackEft;
        }
        else if(c is Ch3_Caiera)
        {
            Ch3_Caiera caiera = c as Ch3_Caiera;
            caiera.showSkill30AAttackEftCallback -= showSkill30AAttackEft;
        }

        int x = 0;
        int lsx = 0;
        if(c.model.transform.localScale.x > 0)
        {
            x = -54;
            lsx = 4;
        }
        else
        {
            x = -54;
            lsx = -4;
        }
        GameObject attackEft = null;

        StaticData.createObjFromPrb(ref attackEftPrb, "eft/Caiera/Skill_CAIERA30A_AttackEft", ref attackEft, c.transform, new Vector3(x, 256, 0), new Vector3(lsx, 4, 1));
    }
        public static Character AddCharacter(this TContext ctx, int userId, Terraria.Player player)
        {
            Character chr = new Character()
            {
                UserId = userId,
                UUID = player.ClientUUId,
                Health = player.statLife,
                MaxHealth = player.statLifeMax,
                Mana = player.statMana,
                MaxMana = player.statManaMax,
                SpawnX = player.SpawnX,
                SpawnY = player.SpawnY,
                Hair = player.hair,
                HairDye = player.hairDye,
                HideVisual = DataEncoding.EncodeInteger(player.hideVisual),
                Difficulty = player.difficulty,
                HairColor = DataEncoding.EncodeColor(player.hairColor),
                SkinColor = DataEncoding.EncodeColor(player.skinColor),
                EyeColor = DataEncoding.EncodeColor(player.eyeColor),
                ShirtColor = DataEncoding.EncodeColor(player.shirtColor),
                UnderShirtColor = DataEncoding.EncodeColor(player.underShirtColor),
                PantsColor = DataEncoding.EncodeColor(player.pantsColor),
                ShoeColor = DataEncoding.EncodeColor(player.shoeColor),
                AnglerQuests = player.anglerQuestsFinished
            };
            ctx.Characters.Add(chr);

            ctx.SaveChanges();

            return chr;
        }
        public void LoadCharacterListFromDisk()
        {
            // Full backup of current saves.
            // Backup();

            var cDirectory = Path.Combine(settings.Game.GameDataPath, "Saves");
            if (!Directory.Exists(cDirectory))
            {
                Directory.CreateDirectory(cDirectory);
            }

            var saves = Directory.GetFiles(cDirectory, "*.ess");
            foreach (var item in saves)
            {
                string file = Path.GetFileName(item);
                string cName = GetCharacterName(item);

                // Search for it in the collection
                Character c = Characters.SingleOrDefault(x => x.Name.Equals(cName, StringComparison.OrdinalIgnoreCase));
                if (c == null)
                {
                    c = new Character(cName);
                    Characters.Add(c);
                }

                if (file != null && !c.Saves.Any(x => x.EndsWith(file, StringComparison.OrdinalIgnoreCase)))
                {
                    c.Saves.Add(item);
                }
            }
        }
 public bool IsAvaible(Character character)
 {
     var rank = character.RanksTaken + 1;
     return MinRank <= rank
         && rank <= MaxRank
         && IsAvaibleCore(character);
 }
Example #24
0
     public static Character Create(int level)
     {
         var toReturn = new Character();
         //todo set stats from an algorithm here.

        return toReturn;
     }
Example #25
0
    public void showEft(Character character)
    {
        Mantis mantis = character as Mantis;

        mantis.skill15BKeyFrameEventCallback -= showEft;
        if(skillEft_MANTIS15BPrb == null)
        {
            skillEft_MANTIS15BPrb = Resources.Load("eft/Mantis/SkillEft_MANTIS15B") as GameObject;
        }

        Destroy(skillEft_MANTIS15B);

        skillEft_MANTIS15B = Instantiate(skillEft_MANTIS15BPrb) as GameObject;

        float x = 0;
        if(mantis.model.transform.localScale.x > 0)
        {
            x = -34;
        }
        else
        {
            x = 34;
        }

        skillEft_MANTIS15B.transform.position = character.transform.position + new Vector3(x, 261, 0);
        skillEft_MANTIS15B.transform.localScale = new Vector3(0.164f, 0.164f, 1);

        StartCoroutine(showBullet(skillEft_MANTIS15B.transform.position));
    }
        public RogueRotationCalculatorCombat(Character character, Stats stats, BossOptions bossOpts, CalculationOptionsRogue calcOpts, float hasteBonus, float mainHandSpeed, float offHandSpeed, float mainHandSpeedNorm,
            float offHandSpeedNorm, float avoidedWhiteMHAttacks, float avoidedWhiteOHAttacks, float avoidedMHAttacks, float avoidedOHAttacks, float avoidedFinisherAttacks,
            float avoidedPoisonAttacks, float chanceExtraCPPerHit, RogueAbilityStats mainHandStats, RogueAbilityStats offHandStats, RogueAbilityStats mainGaucheStats,
            RogueAbilityStats sStrikeStats, RogueAbilityStats rStrikeStats, RogueAbilityStats ruptStats, RogueAbilityStats evisStats, RogueAbilityStats snDStats, RogueAbilityStats exposeStats,
            RogueAbilityStats iPStats, RogueAbilityStats dPStats, RogueAbilityStats wPStats) : base(character, stats, bossOpts, calcOpts, hasteBonus, mainHandSpeed, offHandSpeed, mainHandSpeedNorm,
            offHandSpeedNorm, avoidedWhiteMHAttacks, avoidedWhiteOHAttacks, avoidedMHAttacks, avoidedOHAttacks, avoidedFinisherAttacks, avoidedPoisonAttacks, chanceExtraCPPerHit, mainHandStats,
            offHandStats, ruptStats, snDStats, exposeStats, iPStats, dPStats, wPStats)
        {
            SStrikeStats = sStrikeStats;
            RStrikeStats = rStrikeStats;
            EvisStats = evisStats;
            MainGaucheStats = mainGaucheStats;

            ChanceOnMGAttackOnMHAttack = RV.Mastery.MainGauche + RV.Mastery.MainGauchePerMast * StatConversion.GetMasteryFromRating(stats.MasteryRating);
            EnergyRegenMultiplier = (1f + RV.Mastery.VitalityRegenMult) * (1f + (RV.AR.Duration + (Talents.GlyphOfAdrenalineRush ? RV.Glyph.ARDurationBonus : 0f)) / RV.AR.CD * Talents.AdrenalineRush) * (1f + HasteBonus) - 1f;

            #region Probability tables
            float c = ChanceExtraCPPerHit, h = (1f - c), f = CPOnFinisher, nf = (1f - f);
            _averageNormalCP[1] = 1 * (f + nf * h) + 2 * (nf * c);
            _averageNormalCP[2] = 2 * (f * h + nf * c + nf * h * h) + 3 * (f * c);
            _averageNormalCP[3] = 3 * (f * c + f * h * h + 2 * nf * c * h + nf * h * h * h) + 4 * (f * h * c + nf * c * c + nf * h * h * c);
            _averageNormalCP[4] = 4 * (2 * f * c * h + f * h * h * h + nf * c * c + 3 * nf * c * h * h + nf * h * h * h * h) + 5 * (f * c * c + f * h * h * c + 2 * nf * c * h * c + nf * h * h * h * c);
            _averageNormalCP[5] = 5 * (f * c * c + 3 * f * c * h * h + f * h * h * h * h + 3 * nf * c * c * h + 4 * nf * c * h * h * h + nf * h * h * h * h * h) + 6 * (2 * f * c * h * c + f * h * h * h * c + nf * c * c * c + 3 * nf * c * h * h * c + nf * h * h * h * h * c);

            c = ChanceExtraCPPerHit + ChanceOnCPOnSSCrit * SStrikeStats.CritChance; h = (1f - c);
            _averageSStrikeCP[1] = 1 * (f + nf * h) + 2 * (nf * c);
            _averageSStrikeCP[2] = 2 * (f * h + nf * c + nf * h * h) + 3 * (f * c + nf * h * c);
            _averageSStrikeCP[3] = 3 * (f * c + f * h * h + 2 * nf * c * h + nf * h * h * h) + 4 * (f * h * c + nf * c * c + nf * h * h * c);
            _averageSStrikeCP[4] = 4 * (2 * f * c * h + f * h * h * h + nf * c * c + 3 * nf * c * h * h + nf * h * h * h * h) + 5 * (f * c * c + f * h * h * c + 2 * nf * c * h * c + nf * h * h * h * c);
            _averageSStrikeCP[5] = 5 * (f * c * c + 3 * f * c * h * h + f * h * h * h * h + 3 * nf * c * c * h + 4 * nf * c * h * h * h + nf * h * h * h * h * h) + 6 * (2 * f * c * h * c + f * h * h * h * c + nf * c * c * c + 3 * nf * c * h * h * c + nf * h * h * h * h * c);
            #endregion
        }
Example #27
0
	public void Play(Character target)
	{
#if	UNITY_3_0_0 || UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5
		gameObject.SetActiveRecursively(true);
#else
		gameObject.SetActive(true);
#endif
		// fire a missile
		Vector3 pos = transform.position + new Vector3(0f, startOffset, 0f);
		Vector3 targetPos = target.transform.position + target.targetingOffset;

		// want the missiles to go up a bit before turning to target, so calc a path for 'em
		Vector3[] path = new Vector3[3];
		float distance = Vector3.Distance(pos, targetPos);
		path[0] = pos;
		path[1] = Vector3.MoveTowards(pos, targetPos, distance / 2.3f);
		path[1].y += missileHeightGain;
		path[2] = targetPos;

		GameObject missileGameObject = (GameObject)GameObject.Instantiate(missileFab, pos, Quaternion.identity);
		iTween.MoveTo(missileGameObject, iTween.Hash(
				"speed", missileSpeed,
				"orienttopath", true,
				"path", path,
				"easetype", "linear",
				"oncomplete", "OnFXMissileReachedTarget",
				"oncompletetarget", gameObject,
				"oncompleteparams", missileGameObject
			));
	}
Example #28
0
 public override void Use(Level level, Character actor, Character target)
 {
     //Console.WriteLine("{0} is attacking {1} for {2} damage!", actor.Name, target.Name, actor.AttackDamage);
     var damage = (int)(actor.AttackDamage + level.rnd.Next(-2, 2));
     target.TakeDamage(damage);
     //actor.LastAction = string.Format("Attacked {0} for {1} damage!", target.Name, damage);
 }
 public static void Clear()
 {
     characters = new Dictionary<string, float>();
          allCharacters = new Dictionary<string, Character>();
          charSuspicion = new Dictionary<Character, float>();
          accusedCharacter = null;
 }
Example #30
0
        public void AfterBinderRetraction()
        {
            Character theDuke = new Character("The Duke", "hello world");
            Hashtable bo = new Hashtable();
            bo.Add("THEDUKE", theDuke);

            // first test to confirm that a pre-existing fact is not rededucted
            IInferenceEngine ie = new IEImpl(new FlowEngineBinder(ruleFilesFolder + "testbinder3.ruleml.xbre",
                                                                  BindingTypes.BeforeAfter));

            ie.LoadRuleBase(new RuleML09NafDatalogAdapter(ruleFilesFolder + "testbinder.ruleml",
                                                       		FileAccess.Read));

            ie.Assert(new Fact("retract_target", "education", new Individual(theDuke), new Individual("polite")));
            ie.NewFactHandler += new NewFactEvent(ShowAllNewFacts);
            deducted = 0;
            ie.Process(bo);
            Assert.AreEqual(0, deducted, "The Duke was already polite!");

            // second test to confirm that retracting the fact in the after binder restarts inference
            ie = new IEImpl(new FlowEngineBinder(ruleFilesFolder + "testbinder4.ruleml.xbre",
                                   							 BindingTypes.BeforeAfter));

            ie.LoadRuleBase(new RuleML09NafDatalogAdapter(ruleFilesFolder + "testbinder.ruleml", FileAccess.Read));

            ie.Assert(new Fact("retract_target", "education", new Individual(theDuke), new Individual("polite")));
            ie.NewFactHandler += new NewFactEvent(ShowAllNewFacts);
            deducted = 0;
            ie.Process(bo);
            Assert.AreEqual(1, deducted, "The Duke was re-deducted polite!");
        }
Example #31
0
 public List <SimpleClient> GetClientsNear(Character character)
 {
     return(Clients.Where(x => x != character.Client && character.Position.IsInRange(x.Character.Position, (int)DefineEnum.MAXDISTANCE)).ToList());
 }
            public override void Execute(TriggerBase trigger)
            {
                if (trigger.IsArgumentDefined("target"))
                {
                    Character character = trigger.Get <Character>("target");
                    System.Collections.Generic.IEnumerable <BasePlayerItem> itemsByPattern = Singleton <ItemManager> .Instance.GetItemsByPattern(trigger.Get <string>("pattern"), character.Inventory);

                    using (System.Collections.Generic.IEnumerator <BasePlayerItem> enumerator = itemsByPattern.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            BasePlayerItem current = enumerator.Current;
                            trigger.Reply("'{0}'({1}) Amount:{2} Guid:{3}", new object[]
                            {
                                current.Template.Name,
                                current.Template.Id,
                                current.Stack,
                                current.Guid
                            });
                        }
                        return;
                    }
                }
                System.Collections.Generic.IEnumerable <ItemTemplate> itemsByPattern2 = Singleton <ItemManager> .Instance.GetItemsByPattern(trigger.Get <string>("pattern"));

                int num  = trigger.Get <int>("page") * ItemRemoveCommand.ItemListCommand.LimitItemList;
                int num2 = 0;

                System.Collections.Generic.IEnumerator <ItemTemplate> enumerator2 = itemsByPattern2.GetEnumerator();
                int num3 = 0;

                while (enumerator2.MoveNext())
                {
                    if (num3 >= num)
                    {
                        ItemTemplate current2 = enumerator2.Current;
                        if (num2 < ItemRemoveCommand.ItemListCommand.LimitItemList)
                        {
                            trigger.Reply("'{0}'({1})", new object[]
                            {
                                current2.Name,
                                current2.Id
                            });
                            num2++;
                        }
                        else
                        {
                            trigger.Reply("... (limit reached : {0})", new object[]
                            {
                                ItemRemoveCommand.ItemListCommand.LimitItemList
                            });
                            if (num2 == 0)
                            {
                                trigger.Reply("No results");
                                return;
                            }
                            return;
                        }
                    }
                    num3++;
                }
            }
Example #33
0
 public override bool isCollidingPosition(Microsoft.Xna.Framework.Rectangle position, xTile.Dimensions.Rectangle viewport, bool isFarmer, int damagesFarmer, bool glider, Character character)
 {
     if ((bool)landslide && position.Intersects(landSlideRect))
     {
         return(true);
     }
     if ((bool)railroadAreaBlocked && position.Intersects(railroadBlockRect))
     {
         return(true);
     }
     return(base.isCollidingPosition(position, viewport, isFarmer, damagesFarmer, glider, character));
 }
 public override DialogStatus QuestStatus(Mobile questOwner, Character c)
 {
     return(BaseNPC.QDS(questOwner, c, this));
 }
Example #35
0
 public void SendMessageToNearestClients(Character character, NetworkMessage message)
 {
     GetClientsNear(character).ForEach((SimpleClient x) => {
         x.Send(message);
     });
 }
Example #36
0
 public void SendMouvementMessageToNearestClients(Character character)
 {
     GetClientsNear(character).ForEach((SimpleClient x) => {
         ContextRoleplayHandler.SendMoveObjectSnapshotMessage(x, character.GetHashCode(), (int)character.Position.X, (int)character.Position.Y, (int)character.Position.Z);
     });
 }
Example #37
0
    // This is where the next action is figured out from the script.
    private string nextAction()
    {
        loopCheck++;
        if (loopCheck > 100)
        {
            broken = true;
        }
        if (target != null && !target.alive)
        {
            target = null;
        }
        if (actions[0].Count == 1 || broken)
        {
            return("malfunction");
        }

        //Prevent stack overflows by limiting the nesting.
        if (nest.Count >= 1000 || nest.Count == 0)
        {
            broken = true;
            return("malfunction");
        }

        /*if(nest.Count == 0) {
         *  nest.Add(0);
         *  indices.Add(1);
         * }*/

        if (indices[indices.Count - 1] >= actions[nest[nest.Count - 1]].Count)
        {
            broken = true;
            return(nextAction());
        }
        else
        {
            string command = actions[nest[nest.Count - 1]][indices[indices.Count - 1]];
            if (command.ToUpper().Equals("RTN"))
            {
                nest.RemoveAt(nest.Count - 1);
                indices.RemoveAt(indices.Count - 1);
                return(nextAction());
            }
            if (getSubNum(command + ":") > -1)
            {
                indices[indices.Count - 1]++;
                if (indices[indices.Count - 1] >= actions[nest[nest.Count - 1]].Count)
                {
                    nest.RemoveAt(nest.Count - 1);
                    indices.RemoveAt(indices.Count - 1);
                }
                nest.Add(getSubNum(command + ":"));
                indices.Add(1);
                return(nextAction());
            }
            else if (!inMoveset(command))
            {
                return("malfunction");
            }
            else if (isCondition(command))
            {
                if (checkCondition(command))
                {
                    indices[indices.Count - 1]++;
                    return(nextAction());
                }
                else
                {
                    indices[indices.Count - 1] += 2;
                    return(nextAction());
                }
            }
            else
            {
                string translated = translateCommand(command);
                indices[indices.Count - 1]++;
                return(translated);
            }
        }
    }
Example #38
0
 void DeleteFromInitiative(Character combatant)
 {
     initiativeOrder.Remove(combatant);
 }
Example #39
0
    //Translate a command from what the player types to a state keyword.
    //Helpful for when the language is changed regarding syntax - this is the only place you'll have to change it.
    private string translateCommand(string command)
    {
        command = command.ToUpper();

        if (command.Equals("RDM"))
        {
            float r = GameMaster.random();
            if (r < 0.33)
            {
                command = "MOV";
            }
            else if (r < 0.66)
            {
                command = "LFT";
            }
            else
            {
                command = "RGT";
            }
        }

        if (command.Equals("RDA"))
        {
            float r = GameMaster.random();
            if (r < 0.143)
            {
                command = "MOV";
            }
            else if (r < 0.285)
            {
                command = "LFT";
            }
            else if (r < 0.428)
            {
                command = "RGT";
            }
            else if (r < 0.571)
            {
                command = "MVL";
            }
            else if (r < 0.714)
            {
                command = "MVR";
            }
            else if (r < 0.857)
            {
                command = "MVB";
            }
            else
            {
                command = "FLP";
            }
        }

        //take a step forward.
        if (command.Equals("MOV"))
        {
            if (direction.Equals("right"))
            {
                return("moveRight");
            }
            else if (direction.Equals("left"))
            {
                return("moveLeft");
            }
            else if (direction.Equals("up"))
            {
                return("moveUp");
            }
            else
            {
                return("moveDown");
            }
        }
        //attack
        else if (command.Equals("ATK"))
        {
            if (direction.Equals("right"))
            {
                return("attackRight");
            }
            else if (direction.Equals("left"))
            {
                return("attackLeft");
            }
            else if (direction.Equals("up"))
            {
                return("attackUp");
            }
            else
            {
                return("attackDown");
            }
        }
        //turn left
        else if (command.Equals("LFT"))
        {
            if (direction.Equals("right"))
            {
                direction = "up";
                return("turnRightUp");
            }
            else if (direction.Equals("left"))
            {
                direction = "down";
                return("turnLeftDown");
            }
            else if (direction.Equals("up"))
            {
                direction = "left";
                return("turnUpLeft");
            }
            else
            {
                direction = "right";
                return("turnDownRight");
            }
        }
        //turn right
        else if (command.Equals("RGT"))
        {
            if (direction.Equals("right"))
            {
                direction = "down";
                return("turnRightDown");
            }
            else if (direction.Equals("left"))
            {
                direction = "up";
                return("turnLeftUp");
            }
            else if (direction.Equals("up"))
            {
                direction = "right";
                return("turnUpRight");
            }
            else
            {
                direction = "left";
                return("turnDownLeft");
            }
        }
        //sit still
        else if (command.Equals("IDL"))
        {
            if (direction.Equals("right"))
            {
                return("idleRight");
            }
            else if (direction.Equals("left"))
            {
                return("idleLeft");
            }
            else if (direction.Equals("up"))
            {
                return("idleUp");
            }
            else
            {
                return("idleDown");
            }
        }
        else if (command.Equals("SEE"))
        {
            target = null;
            if (!checkCondition("ESP"))
            {
                return("malfunction");
            }
            else
            {
                int [] coords = getFront();
                while (GameMaster.withinField(coords[0], coords[1]) && target == null && !GameMaster.allyAtSpace(coords[0], coords[1], getTeam()))
                {
                    if (GameMaster.enemyAtSpace(coords[0], coords[1], getTeam()))
                    {
                        target = GameMaster.objectAtSpace(coords[0], coords[1]).GetComponent <Character>();
                    }
                    else
                    {
                        coords = getFront(coords);
                    }
                }
                GameMaster.animate("spotted", transform.position.x, transform.position.y, transform.position.z + 0.01f);
            }
            return(translateCommand("IDL"));
        }

        else if (command.Equals("FLP"))
        {
            translateCommand("LFT");
            return(translateCommand("LFT"));
        }

        else if (command.Equals("ATL"))
        {
            if (direction.Equals("right"))
            {
                characterCommand = "attackUp";
                return("attackRight");
            }
            else if (direction.Equals("left"))
            {
                characterCommand = "attackDown";
                return("attackLeft");
            }
            else if (direction.Equals("up"))
            {
                characterCommand = "attackLeft";
                return("attackUp");
            }
            else
            {
                characterCommand = "attackRight";
                return("attackDown");
            }
        }

        else if (command.Equals("ATR"))
        {
            if (direction.Equals("right"))
            {
                characterCommand = "attackDown";
                return("attackRight");
            }
            else if (direction.Equals("left"))
            {
                characterCommand = "attackUp";
                return("attackLeft");
            }
            else if (direction.Equals("up"))
            {
                characterCommand = "attackRight";
                return("attackUp");
            }
            else
            {
                characterCommand = "attackLeft";
                return("attackDown");
            }
        }

        else if (command.Equals("MVB"))
        {
            if (direction.Equals("right"))
            {
                characterCommand = "moveLeft";
                return("moveRight");
            }
            else if (direction.Equals("left"))
            {
                characterCommand = "moveRight";
                return("moveLeft");
            }
            else if (direction.Equals("up"))
            {
                characterCommand = "moveDown";
                return("moveUp");
            }
            else
            {
                characterCommand = "moveUp";
                return("moveDown");
            }
        }

        else if (command.Equals("MVL"))
        {
            if (direction.Equals("right"))
            {
                characterCommand = "moveUp";
                return("moveRight");
            }
            else if (direction.Equals("left"))
            {
                characterCommand = "moveDown";
                return("moveLeft");
            }
            else if (direction.Equals("up"))
            {
                characterCommand = "moveLeft";
                return("moveUp");
            }
            else
            {
                characterCommand = "moveRight";
                return("moveDown");
            }
        }

        else if (command.Equals("MVR"))
        {
            if (direction.Equals("right"))
            {
                characterCommand = "moveDown";
                return("moveRight");
            }
            else if (direction.Equals("left"))
            {
                characterCommand = "moveUp";
                return("moveLeft");
            }
            else if (direction.Equals("up"))
            {
                characterCommand = "moveRight";
                return("moveUp");
            }
            else
            {
                characterCommand = "moveLeft";
                return("moveDown");
            }
        }

        //Ranged attack
        else if (command.Equals("RAT"))
        {
            if (weaponLoaded)
            {
                int[] coords = getFront();
                while (GameMaster.withinField(coords[0], coords[1]) && weaponLoaded)
                {
                    if (GameMaster.enemyAtSpace(coords[0], coords[1], getTeam()) || GameMaster.allyAtSpace(coords[0], coords[1], getTeam()))
                    {
                        GameMaster.attackSpace(GetComponent <Character>().attack, coords[0], coords[1]);
                        weaponLoaded = false;
                    }
                    else
                    {
                        coords = getFront(coords);
                    }
                }
                weaponLoaded = false; //Keep this if you want the archer to shoot even if they don't shoot a character.

                if (direction.Equals("right"))
                {
                    characterCommand = "rangedRight";
                    return("attackRight");
                }
                else if (direction.Equals("left"))
                {
                    characterCommand = "rangedLeft";
                    return("attackLeft");
                }
                else if (direction.Equals("up"))
                {
                    characterCommand = "rangedUp";
                    return("attackUp");
                }
                else
                {
                    characterCommand = "rangedRight";
                    return("attackRight");
                }
            }
            else
            {
                return("malfunction");
            }
        }

        else if (command.Equals("RLD"))
        {
            weaponLoaded = true;
            return(translateCommand("IDL"));
        }

        else
        {
            return("malfunction");
        }
    }
Example #40
0
 public StackedFocus(Character objCharacter)
 {
     // Create the GUID for the new Focus.
     _guiID        = Guid.NewGuid();
     _objCharacter = objCharacter;
 }
Example #41
0
 void Awake()
 {
     m_Body      = GetComponent <Rigidbody2D>();
     m_Character = GetComponent <Character>();
 }
Example #42
0
 public void RemoveShoes(Character character)
 {
     character.shoes = null;
 }
Example #43
0
 void ResumeBattleAfterDelayWith(Character combatant)
 {
     initiativeOrder.Add(combatant);
     TryToStartTurn();
 }
Example #44
0
 // could be useful to call on-enter effects there?..
 public void SetCharacter(Character c)
 {
     Character = c;
 }
Example #45
0
 public virtual void UpdateCharacterStats(Character character)
 {
 }
Example #46
0
 public static TextParser <decimal[]> MoneyList(char delimiter) =>
 Money.ManyDelimitedBy(Character.EqualTo(delimiter));
 private void setNextCharacter()
 {
     _currentCharacter = _randomizer.GetRandomCharacter();
 }
 public void CloseTerritory(Character character)
 {
     isAccessible = false;
     Console.WriteLine($"Access to territory is now restricted for {character.name}");
 }
Example #49
0
 public SummonSkeleton(Character caster)
     : base(caster)
 {
 }
Example #50
0
        protected override void DoDetection(bool useHead)
        {
            ProfilerShort.Begin("DoDetection");
            if (Character == MySession.Static.ControlledEntity)
            {
                MyHud.SelectedObjectHighlight.RemoveHighlight();
            }

            var head    = Character.GetHeadMatrix(false);
            var headPos = head.Translation - (Vector3D)head.Forward * 0.3; // Move to center of head, we don't want eyes (in front of head)

            Vector3D from;
            Vector3D dir;

            if (!useHead)
            {
                //Ondrej version
                var cameraMatrix = MySector.MainCamera.WorldMatrix;
                dir  = cameraMatrix.Forward;
                from = MyUtils.LinePlaneIntersection(headPos, (Vector3)dir, cameraMatrix.Translation, (Vector3)dir);
            }
            else
            {
                //Petr version
                dir  = head.Forward;
                from = headPos;
            }

            Vector3D to = from + dir * MyConstants.DEFAULT_INTERACTIVE_DISTANCE;

            //EnableDetectorsInArea(from);
            GatherDetectorsInArea(from);
            float        closestDetector    = float.MaxValue;
            IMyEntity    closestEntity      = null;
            IMyUseObject closestInteractive = null;

            foreach (var entity in m_detectableEntities)
            {
                if (entity == Character)
                {
                    continue;
                }
                var use = entity.Components.Get <MyUseObjectsComponentBase>() as MyUseObjectsComponent;
                if (use != null)
                {
                    float detectorDistance;
                    var   interactive = use.RaycastDetectors(from, to, out detectorDistance);
                    if (Math.Abs(detectorDistance) < Math.Abs(closestDetector))
                    {
                        closestDetector    = detectorDistance;
                        closestEntity      = entity;
                        closestInteractive = interactive;
                    }
                }

                //Floating object handling - give FO useobject component!
                var use2 = entity as IMyUseObject;
                if (use2 != null)
                {
                    var m    = use2.ActivationMatrix;
                    var ray  = new RayD(from, to - from);
                    var obb  = new MyOrientedBoundingBoxD(m);
                    var dist = obb.Intersects(ref ray);
                    if (dist.HasValue && Math.Abs(dist.Value) < Math.Abs(closestDetector))
                    {
                        closestDetector    = (float)dist.Value;
                        closestEntity      = entity;
                        closestInteractive = use2;
                    }
                }
            }
            m_detectableEntities.Clear();
            //VRageRender.MyRenderProxy.DebugDrawLine3D(from, to, Color.Red, Color.Green, true);
            //VRageRender.MyRenderProxy.DebugDrawSphere(headPos, 0.05f, Color.Red.ToVector3(), 1.0f, false);

            StartPosition = from;

            MyPhysics.CastRay(from, to, m_hits, MyPhysics.CollisionLayers.FloatingObjectCollisionLayer);

            bool hasInteractive = false;

            int index = 0;

            while (index < m_hits.Count && (m_hits[index].HkHitInfo.Body == null || m_hits[index].HkHitInfo.GetHitEntity() == Character ||
                                            m_hits[index].HkHitInfo.GetHitEntity() == null ||
                                            m_hits[index].HkHitInfo.Body.HasProperty(HkCharacterRigidBody.MANIPULATED_OBJECT) ||
                                            m_hits[index].HkHitInfo.Body.Layer == MyPhysics.CollisionLayers.VoxelLod1CollisionLayer)) // Skip invalid hits and self character
            {
                index++;
            }

            if (index < m_hits.Count && m_hits[index].HkHitInfo.HitFraction > closestDetector - 0.05f)//compensation
            {
                // TODO: Uncomment to enforce that character must face object by front to activate it
                //if (TestInteractionDirection(head.Forward, h.Position - GetPosition()))
                //return;
                HitPosition = from + dir * closestDetector;
                MyUseObjectsComponentBase useObject;
                if (closestEntity.Components.TryGet <MyUseObjectsComponentBase>(out useObject))
                {
                    var detectorPhysics = useObject.DetectorPhysics;
                    HitMaterial = detectorPhysics.GetMaterialAt(HitPosition);
                    HitBody     = ((MyPhysicsBody)detectorPhysics).RigidBody;
                }
                else
                {
                    HitMaterial = closestEntity.Physics.GetMaterialAt(HitPosition);
                    HitBody     = ((MyPhysicsBody)closestEntity.Physics).RigidBody;
                }

                DetectedEntity = closestEntity;
                var interactive = closestInteractive;

                if (UseObject != null && interactive != null && UseObject != interactive)
                {
                    UseObject.OnSelectionLost();
                }

                //if (interactive != null && interactive.SupportedActions != UseActionEnum.None && (Vector3D.Distance(from, (Vector3D)h.Position)) < interactive.InteractiveDistance && Character == MySession.Static.ControlledEntity)
                if (interactive != null && interactive.SupportedActions != UseActionEnum.None && closestDetector * MyConstants.DEFAULT_INTERACTIVE_DISTANCE < interactive.InteractiveDistance && Character == MySession.Static.ControlledEntity)
                {
                    HandleInteractiveObject(interactive);

                    UseObject      = interactive;
                    hasInteractive = true;
                }
            }

            if (!hasInteractive)
            {
                if (UseObject != null)
                {
                    UseObject.OnSelectionLost();
                }

                UseObject = null;
            }

            ProfilerShort.End();
        }
Example #51
0
 public void activeCharacter(Character character, bool active)
 {
     character.setActive(active);
 }
Example #52
0
 public List <ActionButton> GetActionButtons(Character pChar, byte specGroup)
 {
     return(pChar.ActionButtons.Where(action => action.SpecGroup == specGroup).ToList());
 }
Example #53
0
        public void Handle(Character customer, Packet iPacket)
        {
            ShopAction action = (ShopAction)iPacket.ReadByte();

            switch (action)
            {
            case ShopAction.Buy:
            {
                short index    = iPacket.ReadShort();
                int   mapleID  = iPacket.ReadInt();
                short quantity = iPacket.ReadShort();

                ShopItem item = this.Items[index];

                if (customer.Meso < item.PurchasePrice * quantity)
                {
                    return;
                }

                Item purchase;
                int  price;

                if (item.IsRecharageable)
                {
                    purchase = new Item(item.MapleID, item.MaxPerStack);
                    price    = item.PurchasePrice;
                }
                else if (item.Quantity > 1)
                {
                    purchase = new Item(item.MapleID, item.Quantity);
                    price    = item.PurchasePrice;
                }
                else
                {
                    purchase = new Item(item.MapleID, quantity);
                    price    = item.PurchasePrice * quantity;
                }

                if (customer.Items.SpaceTakenBy(purchase) > customer.Items.RemainingSlots(purchase.Type))
                {
                    customer.Notify("Your inventory is full.", NoticeType.Popup);
                }
                else
                {
                    customer.Meso -= price;
                    customer.Items.Add(purchase);
                }

                using (Packet oPacket = new Packet(ServerOperationCode.ConfirmShopTransaction))
                {
                    oPacket.WriteByte();

                    customer.Client.Send(oPacket);
                }
            }
            break;

            case ShopAction.Sell:
            {
                short slot     = iPacket.ReadShort();
                int   mapleID  = iPacket.ReadInt();
                short quantity = iPacket.ReadShort();

                Item item = customer.Items[mapleID, slot];

                if (item.IsRechargeable)
                {
                    quantity = item.Quantity;
                }

                if (quantity > item.Quantity)
                {
                    return;
                }
                else if (quantity == item.Quantity)
                {
                    customer.Items.Remove(item, true);
                }
                else if (quantity < item.Quantity)
                {
                    item.Quantity -= quantity;
                    item.Update();
                }

                if (item.IsRechargeable)
                {
                    customer.Meso += item.SalePrice + (int)(this.UnitPrices[item.MapleID] * item.Quantity);
                }
                else
                {
                    customer.Meso += item.SalePrice * quantity;
                }

                using (Packet oPacket = new Packet(ServerOperationCode.ConfirmShopTransaction))
                {
                    oPacket.WriteByte(8);

                    customer.Client.Send(oPacket);
                }
            }
            break;

            case ShopAction.Recharge:
            {
                short slot = iPacket.ReadShort();

                Item item = customer.Items[ItemType.Usable, slot];

                int price = (int)(this.UnitPrices[item.MapleID] * (item.MaxPerStack - item.Quantity));

                if (customer.Meso < price)
                {
                    customer.Notify("You do not have enough mesos.", NoticeType.Popup);
                }
                else
                {
                    customer.Meso -= price;

                    item.Quantity = item.MaxPerStack;
                    item.Update();
                }

                using (Packet oPacket = new Packet(ServerOperationCode.ConfirmShopTransaction))
                {
                    oPacket.WriteByte(8);

                    customer.Client.Send(oPacket);
                }
            }
            break;

            case ShopAction.Leave:
            {
                customer.LastNpc = null;
            }
            break;
            }
        }
Example #54
0
 public virtual void OnCharacterStay(Character character)
 {
 }
 public void RemoveDisplayForCharacter(Character c)
 {
     SimplePool.Despawn(c.DisplayObject.gameObject);
     c.DisplayObject.ModelObject = null;
     c.AssignDisplayObject(null);
 }
Example #56
0
 internal void SendCharacterLeave(IWorldClient client, Character removedCharacter)
 {
     using var packet = new Packet(PacketType.CHARACTER_LEFT_MAP);
     packet.Write(removedCharacter.Id);
     client.SendPacket(packet);
 }
Example #57
0
 public void Initialize(Character inCharacter) =>
     _targetCharacter = inCharacter;
Example #58
0
 internal void SendLearnedSkills(IWorldClient client, Character character)
 {
     using var packet = new Packet(PacketType.CHARACTER_SKILLS);
     packet.Write(new CharacterSkills(character).Serialize());
     client.SendPacket(packet);
 }
Example #59
0
 internal void SendCharacterMoves(IWorldClient client, Character movedPlayer)
 {
     using var packet = new Packet(PacketType.CHARACTER_MOVE);
     packet.Write(new CharacterMove(movedPlayer).Serialize());
     client.SendPacket(packet);
 }