示例#1
0
    // Use this for initialization
    void Start()
    {
        flickerTime = 0.06f;

        cu = GameObject.FindGameObjectWithTag("Player").GetComponent <CharacterUpdate>();
        ch = GameObject.FindGameObjectWithTag("Player").GetComponent <CharacterHealth>();

        exhaust = GameObject.FindGameObjectWithTag("Exhaust");

        exhaust0 = GameObject.FindGameObjectWithTag("exhaust0");
        exhaust1 = GameObject.FindGameObjectWithTag("exhaust1");
        exhaust2 = GameObject.FindGameObjectWithTag("exhaust2");
        exhaust3 = GameObject.FindGameObjectWithTag("exhaust3");
        exhaust4 = GameObject.FindGameObjectWithTag("exhaust4");
        exhaust5 = GameObject.FindGameObjectWithTag("exhaust5");
        exhaust6 = GameObject.FindGameObjectWithTag("exhaust6");

        exhaust0.SetActive(false);
        exhaust1.SetActive(false);
        exhaust2.SetActive(false);
        exhaust3.SetActive(false);
        exhaust4.SetActive(false);
        exhaust5.SetActive(false);

        exhausts = new GameObject[] { exhaust0, exhaust2, exhaust3, exhaust4, exhaust5, exhaust6 };
    }
示例#2
0
        private void gridWeapon_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;

            if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
                e.RowIndex >= 0 && gridWeapon.Rows[e.RowIndex].Cells["ID"].Value != null)
            {
                string id = gridWeapon.Rows[e.RowIndex].Cells["ID"].Value.ToString();

                if (String.IsNullOrEmpty(id))
                {
                    return;
                }

                XPathDocument  xDoc = new XPathDocument(Global.CharacterFolder + Player.Name + ".xml");
                XPathNavigator xNav = xDoc.CreateNavigator().SelectSingleNode(String.Format("Character/Equipment/Weapons/Weapon[@ID='{0}']/Capacity", id));

                if (xNav != null)
                {
                    int ammoToFull = xNav.SelectSingleNode("Max").ValueAsInt - xNav.SelectSingleNode("Current").ValueAsInt;
                    CharacterUpdate.ManageAmmo(Global.CharacterFolder + Player.Name + ".xml", id, ammoToFull);

                    gridWeapon.Refresh();
                }
            }
        }
示例#3
0
        private void validate(CharacterUpdate update)
        {
            var attributeCounts = new[]
            {
                update.AddedOrUpdatedAllocations?.Select(a => a.Attribute),
                update.RemovedAllocations?.Select(a => a.Attribute),
            }
            .SelectMany(g => EmptyOnNull(g))           // flatten the list<list<attrib>> -> list<attrib>
            .GroupBy(a => a)                           // group same attributes together
            .ToDictionary(g => g.Key, g => g.Count()); // create dictionary: attrib -> count

            var multipleAttributeViolations = attributeCounts
                                              .Where(kvp => kvp.Value > 1);

            if (multipleAttributeViolations.Count() > 0)
            {
                var violationStrings =
                    multipleAttributeViolations.Select(kvp => string.Format("{0}:{1}", kvp.Key.Name, kvp.Key.Category));

                var violationMessage = string.Join(", ", violationStrings);

                throw new Exception(string.Format("update contains multiple references to {0} attributes: {1}",
                                                  multipleAttributeViolations.Count(), violationMessage));
            }
        }
示例#4
0
        private void Sell_Clicked(object sender, EventArgs e)
        {
            Button btn = ((Button)sender);
            string id  = btn.Name.Replace(_acceptButtonPrefix, String.Empty);

            Control       ctrl = pnlNotifications.Controls.Find(_numericPrefix + id, true)[0];
            NumericUpDown num  = ((NumericUpDown)ctrl);

            XmlDocument xDoc = new XmlDocument();

            xDoc.Load(Global.NotificationXml);

            XPathNavigator xNotifNav = xDoc.CreateNavigator().SelectSingleNode(String.Format("Notifications/RequestSell[@ID='{0}']", id));

            CharacterUpdate.RemoveItemFromCharacter(xNotifNav.SelectSingleNode("@Item").Value, id, xNotifNav.SelectSingleNode("@Character").Value);
            CharacterUpdate.AddItemToCharacter(null, "Cash", null, xNotifNav.SelectSingleNode("@Character").Value, Convert.ToInt32(num.Value));

            xNotifNav.DeleteSelf();

            while (Global.IsFileLocked(Global.NotificationXml))
            {
                Thread.Sleep(1000);
            }
            FileStream lvFS = new FileStream(Global.NotificationXml, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite);

            xDoc.Save(lvFS);
            lvFS.Close();
        }
示例#5
0
        private void FormSelected(object sender, EventArgs e)
        {
            XPathDocument  xDoc = new XPathDocument(_formsXml);
            XPathNavigator xNav = xDoc.CreateNavigator().SelectSingleNode(String.Format("Forms/Werewolf/Form[@Name='{0}']", ((RadioButton)sender).Text));

            CharacterUpdate.UpdatePlayerForm(Global.CharacterFolder + Player.Name + ".xml", ((RadioButton)sender).Text);

            SetInfo(xNav);
            //Global.PlayerForm.RefreshAll();
        }
示例#6
0
        private void cmbStatus_SelectedIndexChanged(object sender, EventArgs e)
        {
            Status lvStatus = (Status)cmbStatus.SelectedItem;

            if (lvStatus != null && lvStatus.Name != "")
            {
                CharacterUpdate.AddRemoveStatus(lvStatus.Name, cvXmlFile);
                cmbStatus.SelectedIndex = -1;
            }
        }
示例#7
0
    // Use this for initialization
    void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player");

        sw = GetComponent <Switch>();

        cu        = GameObject.FindGameObjectWithTag("Player").GetComponent <CharacterUpdate>();
        alignment = GameObject.FindGameObjectWithTag("AlignmentAxis").GetComponent <Transform>();

        roundsLabel = GameObject.FindGameObjectWithTag("RoundsLabel").GetComponent <Text>();
        roundsText  = GameObject.FindGameObjectWithTag("Rounds").GetComponent <Text>();
    }
示例#8
0
 private void btnRetrieve_Click(object sender, EventArgs e)
 {
     if (Type != "Cash")
     {
         CharacterUpdate.AddItemToCharacter(lblName.Text, Type, lblID.Text);
     }
     else
     {
         CharacterUpdate.AddItemToCharacter(lblName.Text, Type, lblID.Text, Convert.ToInt32(lblValue.Text));
     }
     Global.RemoveLootItem(ID);
     Global.PlayerForm.UpdateEquipmentTab();
 }
示例#9
0
//	public AudioClip audioClip;

//	int direction = 1;

    // Use this for initialization
    void Start()
    {
        body = GameObject.FindGameObjectWithTag("Body");
        anim = GetComponent <Animator>();
//		sr = GetComponent<SpriteRenderer>();
        characterUpdate = transform.parent.GetComponent <CharacterUpdate>();
        characterHealth = transform.parent.GetComponent <CharacterHealth>();

//		audio = GetComponent<AudioSource>();
        runningSound             = gameObject.AddComponent <AudioSource>();
        runningSound.clip        = runningSoundClip;
        runningSound.playOnAwake = false;
    }
示例#10
0
 void OnCollisionEnter2D(Collision2D other)
 {
     if (other.gameObject.tag == "Player")
     {
         CharacterUpdate cu = other.gameObject.GetComponent <CharacterUpdate>();
         if (cu.maxRocketFuel - cu.rocketFuel > amount / 4f)
         {
             cu.rocketFuel += amount;
             restoreSound.Play();
             Destroy(gameObject, restoreSound.clip.length);
         }
     }
 }
        public IHttpActionResult Put(CharacterUpdate model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var service = CreateCharacterService();

            if (!service.UpdateCharacter(model))
            {
                return(InternalServerError());
            }
            return(Ok());
        }
示例#12
0
    public void Start()
    {
        hb = GameObject.FindGameObjectWithTag("HealthBar").GetComponent <RectTransform>();
        cu = GameObject.FindGameObjectWithTag("Player").GetComponent <CharacterUpdate>();

        painSound = gameObject.AddComponent <AudioSource>();

        painSoundClips = new AudioClip[4];

        painSoundClips[0] = painSoundClip1;
        painSoundClips[1] = painSoundClip2;
        painSoundClips[2] = painSoundClip3;
        painSoundClips[3] = painSoundClip4;
    }
示例#13
0
 private void btnSubt_Click(object sender, EventArgs e)
 {
     if (Global.SelectedActorType == Global.CharType.Character)
     {
         CharacterUpdate.ManageAmmo(Global.CharacterFolder + Global.SelectedActorID + ".xml", lblWeaponId.Text, Convert.ToInt32(numSubt.Value * -1));
     }
     else if (Global.SelectedActorType == Global.CharType.NPC)
     {
         CharacterUpdate.ManageAmmo(Global.NpcFolder + Global.SelectedActorID + ".xml", lblWeaponId.Text, Convert.ToInt32(numSubt.Value * -1));
     }
     else
     {
         //TODO: Exception
     }
     lblAmmo.Text = (Convert.ToInt32(lblCapacityCurrent.Text) - numSubt.Value) + "/" + lblCapacityMax.Text;
 }
示例#14
0
    // Use this for initialization
    void Start()
    {
        cu       = GameObject.FindGameObjectWithTag("Player").GetComponent <CharacterUpdate>();
        sw       = transform.parent.GetComponent <Switch>();
        onSwitch = gameObject.AddComponent <Switch>();

        onLight           = gameObject.AddComponent <Light>();
        onLight.color     = new Color(1.0f, 0, 1.0f);
        onLight.range     = 7;
        onLight.intensity = 5;

        gravSound             = gameObject.AddComponent <AudioSource>();
        gravSound.clip        = gravSoundClip;
        gravSound.loop        = true;
        gravSound.playOnAwake = false;
    }
 public bool UpdateCharacter(CharacterUpdate model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         var entity =
             ctx
             .Characters
             .Single(e => e.Id == model.Id);
         entity.Name           = model.Name;
         entity.Alive          = model.Alive;
         entity.EpisodeOfDeath = model.EpisodeOfDeath;
         entity.HouseId        = model.HouseId;
         entity.Gender         = model.Gender;
         entity.Actor          = model.Actor;
         entity.CauseOfDeath   = model.CauseOfDeath;
         return(ctx.SaveChanges() == 1);
     }
 }
示例#16
0
        private void EquipButton_Clicked(object sender, MouseEventArgs e)
        {
            Boolean lvEquip = ((Button)sender).BackColor == Color.White;
            string  lvName  = ((Button)sender).Name;

            if (lvEquip)
            {
                ((Button)sender).Image     = Properties.Resources.pack_color;
                ((Button)sender).BackColor = Color.Green;
            }
            else
            {
                ((Button)sender).Image     = Properties.Resources.pack;
                ((Button)sender).BackColor = Color.White;
            }

            CharacterUpdate.EquipUnequipItem(lvName, lvEquip);
            Global.PlaySound(Global.Sound_Equip, false);
        }
示例#17
0
        public Character UpdateCharacter(Character character, CharacterUpdate update)
        {
            var updatedAllocations = mergeUpdate(character.Sheet.AttributeAllocations, update);
            var rules   = new CalculationRules(_attributesDb, _contributionsDb, updatedAllocations);
            var results = _calculationService.Calculate(rules);

            var characterSheet = new CharacterSheet
            {
                AttributeAllocations = updatedAllocations.ToList(),
                AttributeValues      = results.AttributeValues,
            };

            _characterSheetsDb.Add(characterSheet);

            character.Sheet = characterSheet;
            _charactersDb.Update(character);

            return(character);
        }
示例#18
0
        private void imgAmmo_Click(object sender, EventArgs e)
        {
            int fullReload = Convert.ToInt32(lblCapacityMax.Text) - Convert.ToInt32(lblCapacityCurrent.Text);

            if (Global.SelectedActorType == Global.CharType.Character)
            {
                CharacterUpdate.ManageAmmo(Global.CharacterFolder + Global.SelectedActorID + ".xml", lblWeaponId.Text, fullReload);
            }
            else if (Global.SelectedActorType == Global.CharType.NPC)
            {
                CharacterUpdate.ManageAmmo(Global.NpcFolder + Global.SelectedActorID + ".xml", lblWeaponId.Text, fullReload);
            }
            else
            {
                //TODO: Exception
            }
            Global.PlaySound(Global.Sound_Reload, false);

            lblAmmo.Text = lblCapacityMax.Text + "/" + lblCapacityMax.Text;
        }
示例#19
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (chkSuccess.Checked)
            {
                switch (ddlDamageType.Text)
                {
                case "Bash":
                    CharacterUpdate.Damage(Convert.ToInt32(numDamage.Value), Global.DamageType.Bash, cvXmlFile);
                    break;

                case "Lethal":
                    CharacterUpdate.Damage(Convert.ToInt32(numDamage.Value), Global.DamageType.Lethal, cvXmlFile);
                    break;

                case "Aggravated":
                    CharacterUpdate.Damage(Convert.ToInt32(numDamage.Value), Global.DamageType.Aggravated, cvXmlFile);
                    break;

                default:
                    break;
                }
            }

            if (lstWeapons.SelectedItem != null)
            {
                ChatboxMessages.CombatDamageWeapon(lstActors.SelectedValue.ToString(), lblEffectedActor.Text, lstWeapons.SelectedItem.ToString(), chkSuccess.Checked, Convert.ToInt32(numDamage.Value));
            }
            else if (lstAbilities.SelectedItem != null)
            {
                ChatboxMessages.CombatDamageAbility(lstActors.SelectedValue.ToString(), lblEffectedActor.Text, lstAbilities.SelectedItem.ToString(), chkSuccess.Checked, Convert.ToInt32(numDamage.Value));
            }
            else
            {
                ChatboxMessages.CombatDamageGeneral(lstActors.SelectedValue.ToString(), lblEffectedActor.Text, chkSuccess.Checked, Convert.ToInt32(numDamage.Value));
            }

            this.Parent.Hide();
        }
示例#20
0
        private void SetInfo(XPathNavigator xNav)
        {
            CharacterUpdate.RemoveBoosts(Global.CharacterFolder + Player.Name + ".xml", _boostSource);

            txtTraits.Clear();
            XPathNodeIterator xNodeIter = xNav.SelectSingleNode("Traits").SelectChildren(XPathNodeType.All);

            while (xNodeIter.MoveNext())
            {
                txtTraits.Text += xNodeIter.Current.Name + " - " + xNodeIter.Current.Value + " : " + xNodeIter.Current.SelectSingleNode("@Value").Value;
                txtTraits.Text += Environment.NewLine;

                CharacterUpdate.AddBoost(Global.CharacterFolder + Player.Name + ".xml", _boostSource, xNodeIter.Current.Name, xNodeIter.Current.Value, xNodeIter.Current.SelectSingleNode("@Value").Value);
            }

            txtDescription.Clear();
            txtDescription.Rtf = RtfHelper.PlainTextToRtf(xNav.SelectSingleNode("Description").Value);

            imgForm.ImageLocation = Properties.Settings.Default.DataLocation + @"Form_Images\" + xNav.SelectSingleNode("Image").Value;

            txtDescription.Refresh();
            txtTraits.Refresh();
            imgForm.Refresh();
        }
示例#21
0
        private IEnumerable <AttributeAllocation> mergeUpdate(IEnumerable <AttributeAllocation> orig, CharacterUpdate update)
        {
            validate(update);

            var overwrittenAttribs = NullSafe(update.AddedOrUpdatedAllocations).Select(a => a.Attribute).Distinct().ToList();
            var overwritten        = orig.Where(a => overwrittenAttribs.Contains(a.Attribute));

            var updated = orig;

            updated = updated.Except(NullSafe(update.RemovedAllocations));
            updated = updated.Except(overwritten);
            updated = updated.Union(NullSafe(update.AddedOrUpdatedAllocations));

            validate(updated);

            return(updated);
        }
示例#22
0
 private void btnSpendWill_Click(object sender, EventArgs e)
 {
     CharacterUpdate.SpendWill(Convert.ToInt32(numSpendWill.Value), cvXmlFile);
 }
示例#23
0
 private void btnRestoreWillFull_Click(object sender, EventArgs e)
 {
     CharacterUpdate.RestoreWill(Convert.ToInt32(numRestoreWill.Value), cvXmlFile, true);
 }
    void Awake()
    {
        manager = GetComponent <GameManager>();

        characters = new CharacterUpdate(manager, this);
    }
示例#25
0
 private void btnHealFull_Click(object sender, EventArgs e)
 {
     CharacterUpdate.Heal(0, cvXmlFile, true);
 }
示例#26
0
 private void btnHeal_Click(object sender, EventArgs e)
 {
     CharacterUpdate.Heal(Convert.ToInt32(numHeal.Value), cvXmlFile, false);
     numHeal.Value = 1;
 }
示例#27
0
 private void btnAggravated_Click(object sender, EventArgs e)
 {
     CharacterUpdate.Damage(Convert.ToInt32(numAggravated.Value), Global.DamageType.Aggravated, cvXmlFile);
     numAggravated.Value = 1;
 }
示例#28
0
 private void btnLethal_Click(object sender, EventArgs e)
 {
     CharacterUpdate.Damage(Convert.ToInt32(numLethal.Value), Global.DamageType.Lethal, cvXmlFile);
     numLethal.Value = 1;
 }
示例#29
0
 // Use this for initialization
 void Start()
 {
     sw = transform.parent.GetComponent <Switch>();
     cu = GameObject.FindGameObjectWithTag("Player").GetComponent <CharacterUpdate>();
 }
示例#30
0
        public void TestInit()
        {
            _attributes    = new InMemoryEntityRepository <Campaigns.Model.Attribute>();
            _contributions = new InMemoryEntityRepository <Campaigns.Model.AttributeContribution>();
            _contributions.AddForeignStore(_attributes);

            _characterSheets = new InMemoryEntityRepository <Campaigns.Model.CharacterSheet>();
            _characters      = new InMemoryEntityRepository <Campaigns.Model.Character>();
            _characters.AddForeignStore(_characterSheets);

            _attributes.AddRange(new[]
            {
                new Campaigns.Model.Attribute {
                    Name = "human", Category = "race", IsStandard = false
                },
                new Campaigns.Model.Attribute {
                    Name = "gnome", Category = "race", IsStandard = false
                },
                new Campaigns.Model.Attribute {
                    Name = "str", Category = "abilities", IsStandard = true
                },
                new Campaigns.Model.Attribute {
                    Name = "int", Category = "abilities", IsStandard = true
                },
                new Campaigns.Model.Attribute {
                    Name = "str", Category = "ability-mods", IsStandard = true
                },
                new Campaigns.Model.Attribute {
                    Name = "int", Category = "ability-mods", IsStandard = true
                },
            });

            _contributions.AddRange(new[]
            {
                Attrib("gnome", "race").ConstantContributionTo(Attrib("int", "abilities"), 2),
                Attrib("str", "abilities").ContributionTo(Attrib("str", "ability-mods"), n => n / 2 - 5),
                Attrib("int", "abilities").ContributionTo(Attrib("int", "ability-mods"), n => n / 2 - 5),
            });

            _rules = new RulesService(
                _attributes,
                _contributions,
                _characterSheets,
                _characters);

            _gnomeAllocations = new []
            {
                new AttributeAllocation {
                    Attribute = Attrib("gnome", "race")
                },
                new AttributeAllocation {
                    Attribute = Attrib("str", "abilities"), Value = 8
                },
                new AttributeAllocation {
                    Attribute = Attrib("int", "abilities"), Value = 8
                },
            };

            _superStrongUpdate = new CharacterUpdate
            {
                AddedOrUpdatedAllocations = new []
                {
                    new AttributeAllocation {
                        Attribute = Attrib("str", "abilities"), Value = 20
                    },
                }
            };
        }