private void updateSlotHelper(WeaponData.Slot slotType, int ammoRemaining, int weaponLevel) { configureSprite(slotType); if (slotType != WeaponData.Slot.Empty) { SlotObject.sprite = this.UnlockedSlotSprite; if (this.BaseAmmo != null && !this.BaseAmmo.activeInHierarchy) this.BaseAmmo.SetActive(true); if (this.AmmoBar != null) { this.AmmoBar.UpdateLength(ammoRemaining, WeaponData.GetSlotDurationsByType()[slotType]); } if (this.TierText != null) { if (weaponLevel == WeaponData.GetMaxSlotsByType()[slotType]) this.TierText.text = "MAX"; else this.TierText.text = "Lv." + weaponLevel; } } else { if (this.AmmoBar != null) this.AmmoBar.EmptyCompletely(); if (this.BaseAmmo != null) this.BaseAmmo.SetActive(false); if (this.TierText != null) this.TierText.text = ""; SlotObject.sprite = this.LockedSlotSprite; } }
public void Fire() { weaponData = gameObject.GetComponentInChildren<WeaponData>(); StartCoroutine(Shoot()); }
public static GameObject CreateWeapon(WeaponData data) { GameObject newWeapon = Instantiate(GetWeaponPrefab(), Vector2.zero, Quaternion.identity) as GameObject; Weapon weapon = newWeapon.GetComponent<Weapon> (); weapon.InitWeapon (data); return newWeapon; }
protected override void OnInitialize(BaseModelParams param) { base.OnInitialize(param); var startParams = param as WeaponModelParams; if (startParams != null) { data = DataManager.GetWeaponData(startParams.WeaponId); } }
private void OnTriggerEnter2D( Collider2D other ) { if( other.tag == "Weapon" && weaponPrefab == null ) { weaponPrefab = other.gameObject as GameObject; weapon = other.GetComponent<WeaponComponent>().weaponData; other.gameObject.SetActive( false ); } }
public Weapon(WeaponData data) : base(data) { Attack = data.Attack; AttackPercent = data.AttackPercent; Magic = data.Magic; CriticalPercent = data.CriticalPercent; LongRange = data.LongRange; Element = data.Element; Wielder = data.Wielder; }
public void ApplyWeaponData(WeaponData data) { m_level = data.level; m_itemID = data.itemID; m_name = data.name; m_attack.m_attackStrength = data.attackStrength; m_attack.m_knockbackForce = data.knockback; m_attack.m_effectType = data.effectType; m_attack.m_effectStrength = data.effectStrength; m_attack.m_effectDuration = data.effectDuration; m_goldCost = data.goldCost; }
/// <summary> /// 將字典傳入,依json表設定資料 /// </summary> public static void SetData(Dictionary<int, WeaponData> _dic) { string jsonStr = Resources.Load<TextAsset>("Json/Weapon").ToString(); JsonData jd = JsonMapper.ToObject(jsonStr); JsonData spellItems = jd["Weapon"]; for (int i = 0; i < spellItems.Count; i++) { WeaponData weaponData = new WeaponData(spellItems[i]); int id = int.Parse(spellItems[i]["ID"].ToString()); _dic.Add(id, weaponData); } }
public CommandUseWeaponSkill(WeaponData weaponData, int skillID) { SkillData skillData = DataManager.Instance.GetSkillDataSet ().GetSkillData (skillID); commandType = CommandType.Attack; commandName = skillData.name; commandDescription = String.Format(skillData.description, "<color=yellow>" + skillData.ATKMultiplier * 100 + "%</color>", "<color=yellow>" + weaponData.interrupt * skillData.interruptMultiplier + "%</color>"); targetType = skillData.targetType; preExecutionSpeed = Mathf.RoundToInt(weaponData.basicSPD * skillData.preSPDMultiplier); postExecutionRecover = skillData.postSPDMultiplier == 0 ? 0 : Mathf.RoundToInt(6000f / weaponData.basicSPD / skillData.postSPDMultiplier); this.skillID = skillID; }
public void Create( Sprite sprite, Object explosion, float fireStrengh, GameObject tank) { Tank = tank; Bomb = new WeaponData() { Damage = Damage, Strength = Strength, BombObj = this.gameObject, Sprite = null, SoruceTank = tank }; }
void SaveWeaponState() { var weaponData = new WeaponData() { WeaponType = WeaponState.WeaponType , CurrentMagazineAmmo = WeaponState.CurrentMagazineAmmo , CurrentTotalAmmo = WeaponState.CurrentTotalAmmo , DamageAmount = WeaponState.DamageAmount , MaxMagazineAmmo = WeaponState.MaxMagazineAmmo , MaxTotalAmmo = WeaponState.MaxTotalAmmo , OneUseTime = WeaponState.OneUseTime , ReloadTime = WeaponState.ReloadTime}; EventTire.SendEvent(TEPath.Up, TireEventType.SaveWeaponStateEvent, weaponData); }
public static WeaponData createWeaponData(WeaponType type) { ItemQuality quality = randQuality(); float level = randLevel(); int damage = Mathf.RoundToInt(type.damage() * level * qualityMultiplier(quality)); float reloadTime = (type.reloadTime() / level) * (quality == ItemQuality.UNIQUE? 0.6f: quality == ItemQuality.SUPERIOR? 0.8f: 1); WeaponData data = new WeaponData(quality, level, type, damage - type.damageRange(), damage + type.damageRange(), reloadTime); data.initCommons(calculateCost(data), calculateEnergy(data)); return(data); }
public void LoadPlayer() { PlayerStats loadedPlayer = SaveSystem.LoadPlayer(); #region private variable setters currClass = loadedPlayer.GetClass(); name = loadedPlayer.GetName(); currMaxHealth = loadedPlayer.GetMaxHealth(); currMaxMP = loadedPlayer.GetMaxMP(); currHP = loadedPlayer.GetCurrHealth(); currMP = loadedPlayer.GetCurrMP(); currAtkPwr = loadedPlayer.GetStr(); currMagicPwer = loadedPlayer.GetInt(); currLevel = loadedPlayer.GetLevel(); location = loadedPlayer.GetLocation(); currWeapon = loadedPlayer.GetEquippedWeapon(); currGold = loadedPlayer.GetGold(); currExp = loadedPlayer.GetExp(); //questList = loadedPlayer.GetQuestList(); currExp = loadedPlayer.GetExp(); Debug.Log("We loaded verything"); Debug.Log("Character info: " + loadedPlayer.GetName() + " " + loadedPlayer.GetClass() + " " + loadedPlayer.GetLevel()); Debug.Log("Weapon info: " + loadedPlayer.GetEquippedWeapon().GetWeaponName() + " " + loadedPlayer.GetEquippedWeapon().GetWeaponDescrpt() + " " + loadedPlayer.GetEquippedWeapon().GetWeaponPwr()); #endregion #region static variable resetters classInfo = loadedPlayer.GetClass(); playerName = loadedPlayer.GetName(); maxHealth = loadedPlayer.GetMaxHealth(); currHealth = loadedPlayer.GetCurrHealth(); maxMP = loadedPlayer.GetMaxMP(); currMP = loadedPlayer.GetCurrMP(); attackPwr = loadedPlayer.GetStr(); level = loadedPlayer.GetLevel(); magicPwr = loadedPlayer.GetInt(); gps = loadedPlayer.GetLocation(); weapon = loadedPlayer.GetEquippedWeapon(); missionList = loadedPlayer.GetQuestList(); exp = loadedPlayer.GetExp(); gold = loadedPlayer.GetGold(); for (int i = 0; i < missionList.Count; i++) { if (missionList[i].GetQuestObjective().goalType == GoalType.ReportTo) { missionList[i].GetQuestObjective().reporter = GameObject.Find(missionList[i].GetQuestObjective().reporterName); } } #endregion }
protected override void OnShow(object userData) { base.OnShow(userData); weaponData = userData as WeaponData; if (weaponData == null) { Log.Error("Weapon data is invalid."); return; } autoWeaponsFireTimeCounter = 0; GameEntry.Entity.AttachEntity(Entity, weaponData.OwnerId, AttachPoint, weaponData); }
public void SetFor(WeaponData WD) { if (WD == null) { gameObject.SetActive(false); return; } wd_stored = WD; SetElementBackground(); SetRarityBorder(); SetTexts(); gameObject.SetActive(true); }
public GenericHero(Vector3 position) { GameObject = Factory.CreateInstance <T>(position, Quaternion.identity); FactoryObject factoryObject = Factory.FetchWeaponDataOfType <T>(); if (factoryObject is FactoryObject_Character characterData) { WeaponData = characterData.WeaponData; } weapon = Factory.CreateInstance <IWeapon>(WeaponData.FetchType(WeaponData.WeaponType), WeaponData); Transform = GameObject.transform; IsAlive = false; Animator = GameObject.GetComponent <Animator>(); }
public override void Setup(object data = null) { base.Setup(data); info = data as NpcInfo; if (info != null) { nameText.text = resourceService.GetString(info.Data.nameId); descriptionText.text = resourceService.GetString(info.Data.descriptionId); iconImage.overrideSprite = resourceService.GetSprite(info.Data.largeIconKey, info.Data.largeIconPath); WeaponData weapon = resourceService.GetWeapon(info.Data.weaponId); weaponIconImage.overrideSprite = resourceService.GetSprite(weapon); weaponNameText.text = resourceService.GetString(weapon.nameId); int playerCount = playerService.GetItemCount(weapon); if (playerCount > 0) { priceParent.gameObject.DeactivateSelf(); buttonText.text = resourceService.GetString("Loc_KillEnPanel_killButton"); buyOrKillButton.SetListener(() => { playerService.RemoveItem(weapon.type, weapon.id, 1); engine.Cast <RavenhillEngine>().DropItems(info.Data.rewards, null, () => !viewService.hasModals); engine.GetService <INpcService>().Cast <NpcService>().RemoveNpc(info.RoomId); Close(); }, engine.GetService <IAudioService>()); weaponIconImage.SetAlpha(1); } else { priceParent.gameObject.ActivateSelf(); priceText.text = weapon.price.price.ToString(); priceImage.overrideSprite = resourceService.GetPriceSprite(weapon.price); buttonText.text = resourceService.GetString("Loc_KillEnPanel_buyButton"); buyOrKillButton.SetListener(() => { if (playerService.HasCoins(weapon.price)) { playerService.RemoveCoins(weapon.price); playerService.AddItem(new InventoryItem(weapon, 1)); Setup(info); } else { viewService.ShowView(RavenhillViewType.bank); } }, engine.GetService <IAudioService>()); weaponIconImage.SetAlpha(0.5f); } } closeBigButton.SetListener(Close, engine.GetService <IAudioService>()); }
public static BasicWeapon CreateNew(WeaponData _weaponsData) { switch (_weaponsData.WeaponType) { case WeaponType.ProjectileWeapon: return(new ProjectileWeapon(_weaponsData)); case WeaponType.Laser: return(new LaserWeapon(_weaponsData)); case WeaponType.snowBall: return(new SnowballWeapon(_weaponsData)); } }
void AddNew(WeaponData weaponData) { playerData.AddWeapon(weaponData); int index = playerData.WeaponCount() - 1; GameObject go = Instantiate(weaponPanelPrefab, transform); go.GetComponent <Button>().onClick.AddListener(() => { OnWeaponPanelClick(go); }); go.GetComponentInChildren <Text>().text = weaponData.weaponName; weaponPanels.Add(go); SetSelected(index); }
override public void Init(Character owner, WeaponData weaponData) { base.Init(owner, weaponData); float stepValue = _weaponData.changeInterval / 4.0f; _stepTime.Clear(); for (int i = 0; i < 6; i++) { _stepTime.Add(stepValue * (i + 1)); } _changeDuration = stepValue; }
public override void Show(object data = null) { base.Show(data); this.data = data as WeaponData; UIEventListener.Get(closeBtn.gameObject).onClick += OnClick; UIEventListener.Get(slotIBtn.gameObject).onClick += OnClick; UIEventListener.Get(slotIIBtn.gameObject).onClick += OnClick; UIEventListener.Get(slotIIIBtn.gameObject).onClick += OnClick; UIEventListener.Get(levelUpBtn.gameObject).onClick += OnClick; Refresh(); }
/// <summary> /// 根据正在使用的武器,计算面板伤害 /// </summary> /// <param name="rh"></param> /// <returns></returns> public Damage ComputerPanelATK(bool rh) { Damage ATK = rh ? rhATK : lhATK; WeaponData wd = am.wm.GetWeaponDataOnUse(rh); if (ATK == null) { ATK = new Damage(); } ATK.physical = wd.weaponItem.ATK.physical + wd.weaponItem.bounusLv.strength * baseStates.strength; // TODO:加敏捷 ATK.magical = wd.weaponItem.ATK.magical + wd.weaponItem.bounusLv.intelligence * baseStates.intelligence; ATK.fire = wd.weaponItem.ATK.fire + wd.weaponItem.bounusLv.intelligence * baseStates.intelligence; return(ATK); }
// Update is called once per frame void Update() { if (weaponChange.changingWeapons) { gun = GameObject.FindGameObjectWithTag("Gun"); weaponData = gun.GetComponentInChildren <WeaponData>(); } if (gun == null) { gun = GameObject.FindGameObjectWithTag("Gun"); } if (weaponData == null) { weaponData = GameObject.FindGameObjectWithTag("FirePoint").GetComponent <WeaponData>(); } if (Input.GetButton("Fire2") && !weaponChange.changingWeapons) { racioHipHold = Mathf.SmoothDamp(racioHipHold, 0, ref racioHipHoldV, weaponData.hipToAimSpeed); playerShooting.isHipAim = 0; playerCamera.fieldOfView = Mathf.Lerp(playerCamera.fieldOfView, weaponData.aimDownFOV, Time.deltaTime * weaponData.smoothFOV); mouseLookX.aimDown = weaponData.aimDownSensitivityX; mouseLookY.aimDown = weaponData.aimDownSensitivityY; weaponData.isAiming = true; Debug.Log("aiming"); } if (!Input.GetButton("Fire2") || weaponChange.changingWeapons) { playerShooting.isHipAim = 1; racioHipHold = Mathf.SmoothDamp(racioHipHold, 1, ref racioHipHoldV, weaponData.hipToAimSpeed); playerCamera.cullingMask |= (1 << 8); playerGUI.aimDown = false; weaponData.isAiming = false; playerCamera.fieldOfView = Mathf.Lerp(playerCamera.fieldOfView, defaultSniperFOV, Time.deltaTime * weaponData.smoothFOV); playerCamera.fieldOfView = defaultSniperFOV; mouseLookX.aimDown = 1f; mouseLookY.aimDown = 1f; } gun.transform.localPosition = new Vector3(weaponData.gunHipPos.x * racioHipHold, weaponData.gunHipPos.y * racioHipHold, gun.transform.localPosition.z); if (Vector3.Distance(gun.transform.localPosition, new Vector3(0, 0, gun.transform.localPosition.z)) < 0.01) { playerGUI.aimDown = true; if (weaponData.gunType == 0) { playerCamera.cullingMask = ~(1 << 8); } } }
private void InitEnemy() { var entity = new FieldEntity(); entity.Name = "Enemy"; var moveData = Movement.Register(entity); moveData.Position = new Vector2(4, 4); moveData.Speed = 3.0f; var collision = Collision.Register(entity); collision.Radius = 0.5f; collision.IsPlayerOwned = false; var health = Health.Register(entity); health.Load(30); var projectile = new ProjectileData() { BaseDamage = 3, DamageVariance = 1, DestroyOnCollision = true, MaxLifetime = 4.0f }; var weapon = new WeaponData() { Projectile = projectile, FireProjectileSpeed = 8f, RateOfFire = 2f, FirePositionOffset = new Vector2(0f, -0.6f), FireDirection = new Vector2(0f, -1f) }; Weapon.RegisterWeapon(entity, weapon); // TODO: view should be not made here but in fieldView var view = Transform.FindObjectOfType <EnemyShipView>(); view.Init(entity); var enemy = new EnemyController(); enemy.Load(entity); _enemies.Add(enemy); }
private void OnWeaponLevelUp(object data) { WeaponData weaponData = data as WeaponData; EntityComponent component = componentsHolder.GetComponent(ComponentDefs.Body); if ((UserManager.GetInstance().user.GetActiveWeapon() != null) && weaponData.id == UserManager.GetInstance().user.GetActiveWeapon().id) { weaponLauncher.Unload(); weaponLauncher.Load(UserManager.GetInstance().user.GetActiveWeapon()); component.PlayFromFrame(0); } }
void Awake() { if (Instance == null) { Instance = this; } else if (Instance != this) { Destroy(gameObject); } cardManager = CardManager.GetInstance(); loses = wins = ties = 0; PlayerWeapon = ComputerWeapon = null; }
void LoadData() { try { wData = Interface.Oxide.DataFileSystem.GetFile("damagescaler_data"); weaponData = Interface.GetMod().DataFileSystem.ReadObject <WeaponData>("damagescaler_data"); InitializeWeaponData(); } catch (Exception ex) { PrintError(ex.ToString()); PrintWarning("Unable to load data, creating new datafile!"); weaponData = new WeaponData(); } }
public Dictionary <RoleAttributeType, float> AttrDict;//属性伤害 持续时间 vs 概率生效 永久性 public Weapon(int id, int level, Role owner) { Data = DataManager.Instance.Weapons[id]; Attrs = DataManager.Instance.WeaponAttributes[id][level]; BaseForceDict[DamageType.BLUNT] = Attrs.DamageBlunt; BaseForceDict[DamageType.ELECTRIC] = Attrs.DamageElectric; BaseForceDict[DamageType.FIRE] = Attrs.DamageFire; BaseForceDict[DamageType.ICE] = Attrs.DamageIce; BaseForceDict[DamageType.MAGIC] = Attrs.DamageMagic; BaseForceDict[DamageType.PIERCE] = Attrs.DamagePierce; BaseForceDict[DamageType.SLASH] = Attrs.DamageSlash; this.Owner = owner; }
public void EquipWeapon(int itemCode) { if (equipedWeapon != null) { UnequipWeapon(); } WeaponData weaponData = ItemDB.Instance.GetWeaponData(itemCode); equipedWeapon = weaponData; PlayerActManager.Instance.EquipWeapon(equipedWeapon); InteractChecker.EquipWeapon(); ApplyItemStat(equipedWeapon.WeaponStat, equipedWeapon.ItemCode); }
public string GetReason(WeaponData computer) { if (this.IsWinner(computer)) { return(this.reasons[computer.weapon]); } else if (computer.IsWinner(this)) { return(computer.reasons[this.weapon]); } else { return("Tie Game!"); } }
//对现存的所有武器进行回收 public void ClearWeapon() { //对字典中的每一个键值对 foreach (KeyValuePair <int, List <WeaponData> > pair in usingWeapon_) { //取出怪物链表 List <WeaponData> usingWeapon = pair.Value; //对链表中的每一武器进行回收 while (usingWeapon.Count != 0) { WeaponData weapon = usingWeapon[0]; FreeWeapon(weapon); } } }
private string DamageBonusInfoString(WeaponData weaponData, UnitWeaponCombiner.DamageBonus bonus) { string result = ""; if (bonus.Value > 0) { result += string.Format("({0} - {1} ", weaponData.MinDamage, weaponData.MaxDamage); if (bonus.StrComponent > 0) { result += string.Format("<#FF4444>+ {0:F0}</color>", bonus.StrComponent); } result += ")"; } return(result); }
private string SpeedBonusInfoString(WeaponData weaponData, UnitWeaponCombiner.SpeedBonus bonus) { string result = ""; if (bonus.Value > 0) { result += string.Format("({0:F2} ", weaponData.AttacksPerSecond); if (bonus.DexComponent > 0) { result += string.Format("<#44FF44>+ {0:F2}</color>", bonus.DexComponent); } result += ")"; } return(result); }
public EnemyData getEnemy(int roomID, float lifeModifier) { EnemyData enemyData = new EnemyData(); enemyData.type = getRandomEnemyIndex(); WeaponData currentPlayerWeapon = Globals.GetPlayerController().WeaponData; enemyData.Life = lifeModifier * ((currentPlayerWeapon.Tier * Random.Range(5f, 20f))) + ((roomID * 5) * Random.Range(1f, 1.5f));//Mathf.RoundToInt((27 + (currentPlayerWeapon.Tier * 5)) * 5 / (dmg_calc(roomID, currentPlayerWeapon, enemyData)) * lifeModifier); addWeaknessesAndResistences(enemyData); enemyData.PowerUpData = PowerUpFactory.getInstance().GetRandomPowerUp(); enemyData.Scale = Random.Range(Constants.ENEMY_MIN_SCALE, Constants.ENEMY_MAX_SCALE); addRandomColorOverlay(enemyData); return(enemyData); }
public Status GetGameStatus(WeaponData player, WeaponData computer) { if (player.weapon == computer.weapon) { return(Status.Tie); } else if (player.IsWinner(computer)) { return(Status.Win); } else { return(Status.Lose); } }
public static WeaponRuntime Parse(WeaponData weaponData) { WeaponRuntime runtime; if (weaponData.weaponType == WeaponType.枪) { runtime = new Gun(); } else { runtime = new WeaponRuntime(); } runtime.weaponData = weaponData; return(runtime); }
public GameObject CreateWeapon(string weaponName, Transform parent) { GameObject prefab = Resources.Load <GameObject>(weaponName); var obj = Object.Instantiate(prefab); obj.transform.parent = parent; obj.transform.position = Vector3.zero; obj.transform.rotation = Quaternion.identity; WeaponData wData = obj.AddComponent <WeaponData>(); wData.atk = weaponDB.GetData <int>(weaponName, "ATK"); return(obj); }
public WeaponInfo(WeaponData data) { this.power = data.power; this.ammoType = data.ammoType; this.ammo = data.maxAmmo; this.maxAmmo = data.maxAmmo; this.fireType = data.fireType; this.fireRate = data.fireRate; this.fireTimer = 0f; this.isCharging = false; this.maxChargeTime = data.maxChargeTime; this.chargeTimer = 0f; this.weaponType = data.weaponType; this.weaponPrefab = data.weaponPrefab; }
private void UpdateWeapon(float deltaTime) { if (newWeapon) { if (weaponTimer < weaponTime) { weaponTimer += deltaTime; } else { weapon = previousWeapon; newWeapon = false; } } }
void Start() { animator = GetComponentInChildren <Animator>(); weaponData = gameObject.GetComponentInChildren <WeaponData>(); //weaponType = gameObject.GetComponentInChildren<WeaponData>().weaponType; fxManagerOBJ = GameObject.Find("FXManager"); fxManager = fxManagerOBJ.GetComponent <FXManager>(); if (fxManager == null) { Debug.Log("Couldn't Find FXManager"); } Debug.Log(this.weaponData.damage); }
/// <summary> /// Инициализация оружия /// </summary> /// <param name="_weaponData">Дата оружия</param> /// <param name="_owner">Хозяин оружия</param> public void InitWeapon(WeaponData _weaponData, AvatarWeaponController _owner) { avatarOwner = _owner; weaponData = _weaponData; if (socketBullet != null) { if (socketBullet.childCount > 0) { fxEffect = socketBullet.GetChild(0).gameObject; } } hitData = new HitData(weaponData.DamageWeapon, avatarOwner); }
private void Start() { if (instance == null) { instance = this; EventSystem <PickupLootEvent> .RegisterListener <LootData_Weapon>(OnPickUpLoot_Weapon); weapons = new Dictionary <WeaponType, WeaponData>(); for (int i = 0; i < listOfWeapons.Count; i++) { WeaponData weaponData = listOfWeapons[i]; weapons.Add(weaponData.WeaponType, weaponData); } } }
/// <summary> /// 起始設定 /// </summary> public MainChara(byte _index, Dictionary<string, string> _attrsDic) { AttrsDic = _attrsDic; Index = _index; ID = int.Parse(AttrsDic["ID"]); Role = GameDictionary.RoleDic[int.Parse(AttrsDic["Role"])]; Level = int.Parse(AttrsDic["Level"]); CurExp = int.Parse(AttrsDic["Exp"]); Point = int.Parse(AttrsDic["Point"]); GrowConstitution = int.Parse(AttrsDic["Constitution"]); GrowStrength = int.Parse(AttrsDic["Strength"]); GrowMind = int.Parse(AttrsDic["Mind"]); GrowFaith = int.Parse(AttrsDic["Faith"]); GrowAlert = int.Parse(AttrsDic["Alert"]); GrowWill = int.Parse(AttrsDic["Will"]); GrowSkill = int.Parse(AttrsDic["Skill"]); GrowAgility = int.Parse(AttrsDic["Agility"]); //狀態 CurHealth = int.Parse(AttrsDic["CurHP"]); CurVitality = int.Parse(AttrsDic["CurVP"]); //天賦 MyTalent = GameDictionary.TalentDic[int.Parse(AttrsDic["Talent"])]; //武器 MyWeapons = new WeaponData[2]; int[] weaponIDs = TextManager.StringSplitToIntArray(AttrsDic["Weapon"], ','); for (int i = 0; i < MyWeapons.Length; i++) { if (i < weaponIDs.Length) MyWeapons[i] = GameDictionary.WeaponDic[weaponIDs[i]]; else MyWeapons[i] = null; } //主防具 MyArmor = GameDictionary.ArmorDic[int.Parse(AttrsDic["Armor"])]; //副防具 MyProtectors = new ProtectorData[4]; int[] ProtectorIDs = TextManager.StringSplitToIntArray(AttrsDic["Protector"], ','); for (int i = 0; i < MyProtectors.Length; i++) { if (i < ProtectorIDs.Length) MyProtectors[i] = GameDictionary.ProtectorDic[ProtectorIDs[i]]; else MyProtectors[i] = null; } }
void LoadWeaponState() { var _params = new object[] { WeaponState.WeaponType, null }; EventTire.SendEvent(TEPath.Up, TireEventType.LoadWeaponStateEvent, _params); var weaponData = (WeaponData)_params[1]; if (weaponData == null) { weaponData = new WeaponData(); WeaponCards.FillWithDefault(WeaponState.WeaponType, weaponData); } WeaponState.CurrentMagazineAmmo = weaponData.CurrentMagazineAmmo; WeaponState.CurrentTotalAmmo = weaponData.CurrentTotalAmmo; WeaponState.OneUseTime = weaponData.OneUseTime; WeaponState.ReloadTime = weaponData.ReloadTime; WeaponState.MaxMagazineAmmo = weaponData.MaxMagazineAmmo; WeaponState.MaxTotalAmmo = weaponData.MaxTotalAmmo; WeaponState.DamageAmount = weaponData.DamageAmount; }
void OnAmmoPickupEvent(object param) { AmmoPickup ammoPickup = (AmmoPickup)param; var weaponType = ammoPickup.WeaponType; // if not current weapon if ((WeaponaryState.CurrentWeaponIndex < 0) || (WeaponaryState.GetOwnedWeaponType(WeaponaryState.CurrentWeaponIndex) != weaponType)) { var weaponData = WeaponaryState.LoadKnownWeapon(weaponType); if (weaponData == null) { weaponData = new WeaponData(); WeaponCards.FillWithDefault(weaponType, weaponData); } weaponData.CurrentTotalAmmo = Mathf.Min(weaponData.CurrentTotalAmmo + ammoPickup.AmmoCount, weaponData.MaxTotalAmmo); WeaponaryState.SaveKnownWeapon(weaponData); } }
public PlayerData(SerializationInfo info, StreamingContext context) { weapons = new List<WeaponData> (); foreach(SerializationEntry entry in info) { switch(entry.Name) { case "count": count = (int)info.GetValue ("count", typeof(int)); break; case "weaponCount": for (int i = 0; i < (int)info.GetValue("weaponCount", typeof(int)); i++){ WeaponData current = new WeaponData (); current.SetCooldown ((int)info.GetValue ("weaponCD_" + i, typeof(int))); weapons.Add (current); } break; } } }
void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); playerData = Resources.Load("Data/PlayerData")as PlayerData; monsterData = Resources.Load("Data/MonsterData")as MonsterData; stageData = Resources.Load("Data/StageData")as StageData; equipmentData = Resources.Load("Data/EquipmentData")as EquipmentData; weaponData = Resources.Load("Data/WeaponData")as WeaponData; } else { Destroy(gameObject); } }
public void Create(Sprite sprite, Object explosion, float fireStrengh, GameObject tank) { Tank = tank; Bomb = new WeaponData() { Damage = 200, Strength = 100, BombObj = this.gameObject, Drag = this.Drag, SizeInital = new Vector3(0.7f, 0.7f, 0.7f), SizeFinal = new Vector3(0.9f, 0.9f, 0.9f), ExplosionSize = new Vector3(0.4f, 0.4f, 0.4f), IntialPeriod = 0.5f, SpriteColor = Color.red, Sprite = sprite, ExplosionPrefap = explosion, Mass = 0.5f, FireSpeed = fireStrengh, SoruceTank = tank }; }
void Start () { if(weapons.Length == 0) { MF_ElectroWeapon[] w = this.GetComponentsInChildren<MF_ElectroWeapon>(); weapons = new WeaponData[w.Length]; for(int i = 0;i<w.Length;i++) { weapons[i] = new WeaponData(); weapons[i].weapon = w[i].gameObject; weapons[i].script = w[i]; } } if (CheckErrors() == true) { return; } turretScript = GetComponent<ST_ElectroTurret>(); if ( GetComponent<MF_AbstractTargeting>() ) { targetingScript = GetComponent<MF_AbstractTargeting>(); } // cache scripts for all weapons if ( weapons.Length > 0 ) { for (int wd=0; wd < weapons.Length; wd++) { if (weapons[wd].weapon) { weapons[wd].script = weapons[wd].weapon.GetComponent<MF_ElectroWeapon>(); } } //set fixed converge angle of weapons relative to weaponMount forward direction, to converge at given range. 0 = no fixed convergence if (fixedConvergeRange > 0) { for (int w=0; w < weapons.Length; w++) { if (weapons[w].weapon) { weapons[w].weapon.transform.rotation = Quaternion.LookRotation( turretScript.weaponMount.transform.position + ( turretScript.weaponMount.transform.forward * fixedConvergeRange ) - weapons[w].weapon.transform.position, turretScript.weaponMount.transform.up ); } } } } }
public void Create( Sprite sprite, Object explosion, float fireStrengh, GameObject tank) { Tank = tank; Bomb = new WeaponData() { Damage = 80, Strength = 80, BombObj = this.gameObject,Drag = this.Drag, SizeInital = new Vector3(0.1523757f, 0.1523757f, 0.1523757f), SizeFinal = new Vector3(0.25f, 0.25f, 0.25f), ExplosionSize = new Vector3(1.5f, 1.5f, 1.5f), IntialPeriod = 0.5f, RadiusOfExplosion =3, SpriteColor = Color.white, Sprite = sprite, ExplosionPrefap = explosion, Mass = 0.5f, FireSpeed = fireStrengh, SoruceTank = tank }; }
public void Create( Sprite sprite, Object explosion, float fireStrengh, GameObject tank) { Tank = tank; this.transform.eulerAngles = new Vector3(0, 0, 315); Bomb = new WeaponData() { Damage = 100, Strength = 100, BombObj = this.gameObject,Drag = this.Drag, SizeInital = new Vector3(0.1523757f, 0.1523757f, 0.1523757f), SizeFinal = new Vector3(0.5f, 0.5f, 0.5f), ExplosionSize = new Vector3(1,1,1), RadiusOfExplosion = 4f, IntialPeriod = 0.5f, SpriteColor = Color.white, Sprite = sprite, ExplosionPrefap = explosion, Mass = 0.5f, FireSpeed = fireStrengh, SoruceTank = tank }; }
public void Create(Sprite sprite, Object explosion, float fireStrengh, GameObject tank) { Tank = tank; Bomb = new WeaponData() { Damage = 50, Strength = 25, BombObj = this.gameObject, Drag = this.Drag, SizeInital = new Vector3(0.04715929f, 0.04715929f, 0.04715929f), SizeFinal = new Vector3(0.09457242f, 0.09457242f, 0.09457242f), ExplosionSize = new Vector3(0.9f, 0.9f, 0.9f), RadiusOfExplosion = 2f, IntialPeriod = 0.5f, SpriteColor = new Color32(191, 0, 0, 255), Sprite = sprite, ExplosionPrefap = explosion, Mass = 0.5f, FireSpeed = fireStrengh, SoruceTank = tank }; }
public void EditList() { int maxCount = GetSelectWindowCount( "UnitSelectWindow"); unitData = new UnitData[6]; teamA = new UnitData[6]; teamASlot = new UnitSlotData[6,4]; keepData = new UnitData[1]; weaponData = new WeaponData[6]; keepWeaponData = new WeaponData[1]; for ( int i = 0; i < maxCount; i++ ) { string charName = GetCharName ( i ); string weaponName = GetWeaponName ( i ); // ----- weaponData[i] = new WeaponData ( i, weaponName, ( ( i + 1 ) * 2 ) ); GameObject _weaponNameText = GameObject.Find ( "WeaponText_List (" + i + ")" ); _weaponNameText.GetComponent<Text>().text = weaponData[i].weapon_name.ToString(); GameObject _weaponAttackText = GameObject.Find ( "WeaponAttack_Text (" + i + ")" ); _weaponAttackText.GetComponent<Text>().text = weaponData[i].attack.ToString(); for ( int j = 0; j < 4; j++ ) { teamASlot[i,j] = new UnitSlotData ( i, GetWeaponName( j ), ( ( i + 1 ) * 2 ) ); Debug.Log ( j + ": " + teamASlot[i,j] ); } // ----- unitData[i] = new UnitData( ( i ), charName, ( i ) ); teamA[i] = new UnitData( ( i ), charName, ( i ) ); GameObject selWindow = GameObject.Find ( "CharSelect_List (" + i.ToString() + ")" ); selectWindowList.Add( selWindow ); GameObject teamAWindow = GameObject.Find ( "UnitSlot (" + i.ToString() + ")" ); teamAWindowList.Add( teamAWindow ); GameObject teamAPowerText = GameObject.Find ( "PowerInfo_Text (" + i + ")" ); teamAPowerText.GetComponent<Text>().text = ( "合計攻撃力:" + teamA[i].attack.ToString() ); GameObject teamACharText = GameObject.Find ( "TeamACharText_List (" + i + ")" ); teamACharText.GetComponent<Text>().text = GetCharName (i); // 部隊外分 GameObject childSprite = selectWindowList[i].gameObject.transform.FindChild("CharSprite_Panel/CharSprite_List (" + i.ToString() + ")" ).gameObject; childSprite.GetComponent<Image>().sprite = Resources.Load<Sprite> ( "Sprites/Character/MiniChar_" + unitData[i].char_no.ToString() ); GameObject childText = GameObject.Find ( "CharText_List (" + i + ")" ); charName = GetCharName ( unitData[i].char_no ); childText.GetComponent<Text>().text = charName; // 部隊分 GameObject teamASprite = GameObject.Find ("SpriteSlot (" + i.ToString() + ")" ).gameObject; teamASprite.GetComponent<Image>().sprite = Resources.Load<Sprite> ( "Sprites/Character/MiniChar_" + unitData[i].char_no.ToString() ); } }
public SlotWrapper(WeaponData.Slot slotType) { this.SlotType = slotType; this.AmmoRemaining = WeaponData.GetSlotDurationsByType()[slotType]; }
public static void PickupSlot(int playerIndex, WeaponData.Slot slotType) { int count = 0; List<ProgressData.SlotWrapper> slots = new List<ProgressData.SlotWrapper>(WeaponSlotsByPlayer[playerIndex]); foreach (ProgressData.SlotWrapper slot in slots) { if (slot.SlotType == slotType) ++count; } if (count < WeaponData.GetMaxSlotsByType()[slotType]) { slots.Add(new ProgressData.SlotWrapper(slotType)); } else { int shots = WeaponData.GetSlotDurationsByType()[slotType]; int shotsToAdd = shots; for (int i = slots.Count - 1; i >= 0; --i) { ProgressData.SlotWrapper slot = slots[i]; if (slot.SlotType == slotType) { slot.AmmoRemaining += shotsToAdd; if (slot.AmmoRemaining > shots) { shotsToAdd = slot.AmmoRemaining - shots; slot.AmmoRemaining = shots; } else { break; } } } } UpdatePlayerSlots(playerIndex, slots.ToArray()); }
public SmartSlot(WeaponData.Slot slotType, int ammo, int level) { this.SlotType = slotType; this.Ammo = ammo; this.Level = level; }
public void FireWeapon(Vector3 orig, Vector3 dir) { if(weaponData==null) { weaponData = gameObject.GetComponentInChildren<WeaponData>(); if(weaponData==null) { Debug.LogError("Did not find any WeaponData in our children!"); return; } } if(cooldown > 0) { return; } Debug.Log ("Firing our gun!"); Ray ray = new Ray(orig, dir); Transform hitTransform; Vector3 hitPoint; hitTransform = FindClosestHitObject(ray, out hitPoint); if(hitTransform != null) { Debug.Log ("We hit: " + hitTransform.name); // We could do a special effect at the hit location // DoRicochetEffectAt( hitPoint ); Health h = hitTransform.GetComponent<Health>(); while(h == null && hitTransform.parent) { hitTransform = hitTransform.parent; h = hitTransform.GetComponent<Health>(); } // Once we reach here, hitTransform may not be the hitTransform we started with! if(h != null) { // This next line is the equivalent of calling: // h.TakeDamage( damage ); // Except more "networky" PhotonView pv = h.GetComponent<PhotonView>(); if(pv==null) { Debug.LogError("Freak out!"); } else { TeamMember tm = hitTransform.GetComponent<TeamMember>(); TeamMember myTm = this.GetComponent<TeamMember>(); if(tm==null || tm.teamID==0 || myTm==null || myTm.teamID==0 || tm.teamID != myTm.teamID ) { h.GetComponent<PhotonView>().RPC ("TakeDamage", PhotonTargets.AllBuffered, weaponData.damage); } } } if(fxManager != null) { DoGunFX(hitPoint); } } else { // We didn't hit anything (except empty space), but let's do a visual FX anyway if(fxManager != null) { hitPoint = Camera.main.transform.position + (Camera.main.transform.forward*100f); DoGunFX(hitPoint); } } cooldown = weaponData.fireRate; }
// Update is called once per frame void Update() { if(Input.GetButton("Fire1") && !freeze) { //shoot Fire(); } if (timerHitmarker > 0f) { //show hitmarker for timer intervall hitmarker.guiTexture.enabled = true; timerHitmarker -= Time.deltaTime; } else hitmarker.guiTexture.enabled = false; if(Input.GetKeyDown(KeyCode.Alpha1)) { //MG or spinfusor DisableWeapons(); gameObject.transform.FindChild("soldier/Hips/Spine/Spine1/Spine2/RightShoulder/RightArm/RightForeArm/RightHand/WeaponHolder/automatic").gameObject.SetActive(true); weaponData = gameObject.GetComponentInChildren<WeaponData>(); } if(Input.GetKeyDown(KeyCode.Alpha2)) { //pistol or grenades DisableWeapons(); gameObject.transform.FindChild("soldier/Hips/Spine/Spine1/Spine2/RightShoulder/RightArm/RightForeArm/RightHand/WeaponHolder/pistol").gameObject.SetActive(true); weaponData = gameObject.GetComponentInChildren<WeaponData>(); } if (Input.GetKeyDown(KeyCode.Alpha3)) { //knife DisableWeapons(); gameObject.transform.FindChild("soldier/Hips/Spine/Spine1/Spine2/RightShoulder/RightArm/RightForeArm/RightHand/WeaponHolder/knife").gameObject.SetActive(true); weaponData = gameObject.GetComponentInChildren<WeaponData>(); } }
void Start() { fxManager = GameObject.FindObjectOfType<FXManager>(); if(fxManager == null) { Debug.LogError("Couldn't find an FXManager."); } hitmarker = GameObject.Find("Hitmarker"); if (weaponData == null) { weaponData = gameObject.GetComponentInChildren<WeaponData>(); if (weaponData == null) { Debug.LogError("Did not find any WeaponData in our children!"); return; } } }
void Fire() { if (weaponData == null) { weaponData = gameObject.GetComponentInChildren<WeaponData> (); if (weaponData == null) { Debug.Log ("Did not find any WeaponData in our children"); return; } } if (cooldown > 0) { return; } anim.SetBool ("Jumping", false); Debug.Log ("Firing our weapon!"); Ray ray = new Ray(Camera.main.transform.position, Camera.main.transform.forward); Transform hitTransform; Vector3 hitPoint; hitTransform = FindClosestHitObject (ray, out hitPoint); // hit something if (hitTransform != null) { Debug.Log("We hit: " + hitTransform.name); Health h = hitTransform.GetComponent<Health>(); while(h == null && hitTransform.parent) { hitTransform = hitTransform.parent; h = hitTransform.GetComponent<Health>(); } //Once we get here hitTransform may not be what we started with // EX: hit the graphics but the crate has the health if (h != null) { // Equivalent of running h.TakeDamage(damage); but is sent across the network PhotonView pv = h.GetComponent<PhotonView>(); if(pv == null) { Debug.Log ("No PhotonView found"); } else { TeamMember tm = hitTransform.GetComponent<TeamMember>(); TeamMember myTm = this.GetComponent<TeamMember>(); if(tm==null || tm.teamID == 0 || myTm == null || myTm.teamID == 0 || tm.teamID != myTm.teamID) { pv.RPC("TakeDamage", PhotonTargets.AllBuffered, weaponData.damage); } } } if (fxManager != null) { DoGunFX(hitPoint); } } // we hit empty space else { if (fxManager != null) { hitPoint = Camera.main.transform.position + (Camera.main.transform.forward * 100f); DoGunFX(hitPoint); } } cooldown = weaponData.fireRate; }