void Start()//游戏初始化上 { isPlayerSide = true; //玩家身体 获取2D刚体组件 body = GetComponent <Rigidbody2D>(); //获取我的渲染变量在渲染精灵上的组件 myRender = GetComponent <SpriteRenderer>(); //我的动画变量获取动画控制器 myAni = GetComponent <Animator>(); //实例化护甲类——用于调用护甲类上的方法 myArmor = new Armor1(1); //现在持有武器变量 获得 boomerang武器的实例 currentWeapon = new Boomerang(firePoint, true); //现在血量 存储最大血量的值——? CurrentHp = maxHp; //碰撞体变量获得碰撞体组件 col = GetComponent <Collider2D>(); //敌人变量挂找到标签为Enemy2的物体 enemy = GameObject.FindGameObjectWithTag("Enemy2"); //ui挂找到GameUI身上的的物体与UIManager类上的组件 ui = GameObject.Find("GameUI").GetComponent <UIManager>(); ui.ChangePlayerHp(currentHp, maxHp, hpBarPoint); hpBarPoint = transform.Find("HpBarPoint"); //SetEnglishName("Doraemon"); //ReadWordDictionary.SetChineseAndEnglishName(this); }
public void EquipWeaponRH(Weapon1 weaponToEquip) //FOR RIGHT HAND { if (equippedWeaponRH != null) //If equipped projectile is not = to none, destroy the current gameobject { Destroy(equippedWeaponRH.gameObject); } equippedWeaponRH = Instantiate(weaponToEquip, weaponHoldRH.position, weaponHoldRH.rotation) as Weapon1; //Instantiates/Equips the projectile and it's position/rotation in relation to WEAPONHOLD equippedWeaponRH.transform.parent = weaponHoldRH; //Weapon is child of the WEAPONHOLD so it moves with the player }
// Use this for initialization void Start() { rangedWeapons rW = new rangedWeapons(); Weapon1 w1 = new Weapon1(); Weapon2 w2 = new Weapon2(); generatedWeapons = new weapons[] { rW, w1, w2 }; rW.create("Ammo_1", rW, miejsca[0].GetComponent <Transform>().position); w1.create("Ammo_2", w1, miejsca[1].GetComponent <Transform>().position); w2.create("Ammo_3", w2, miejsca[2].GetComponent <Transform>().position); }
public bool Equals(Gang other) { if (other == null) { return(false); } return(VehicleModel.Equals(other.VehicleModel) && PedModelOverride.Equals(other.PedModelOverride) && Weapon1.Equals(other.Weapon1) && Weapon2.Equals(other.Weapon2)); }
void OnTriggerEnter2D(Collider2D col) { if (col.tag == "bullet") { Weapon1 weapon = Players.p.playerOne.GetComponent <Weapon1>(); HP -= weapon.damage; } if (HP <= 0) { Players.p.money += bounty; Die(); } }
void OnTriggerEnter2D(Collider2D col) { if (col.tag == "bullet") { Weapon1 weapon = Players.p.playerOne.GetComponent <Weapon1>(); HP -= weapon.damage; FindObjectOfType <AudioManager>().Play("EnemyHurt"); } if (HP <= 0) { Players.p.money += bounty; Die(); } }
// Use this for initialization void Start() { CharacterA characterA = new CharacterA("xiaoming"); CharacterB characterB = new CharacterB("lisi"); Weapon1 weapon1 = new Weapon1("weapon1"); Weapon2 weapon2 = new Weapon2("weapon2"); characterA.SetWeapon(weapon2); characterB.SetWeapon(weapon1); characterA.Attack(); characterB.Attack(); }
//受保护 初始化的 虚方法 protected virtual void OnAwake() { //我的动画获取动画管理器组件子对象 myAni = GetComponentInChildren <Animator>(); //我的刚体获取刚体组件 myRig = GetComponent <Rigidbody2D>(); //我的碰撞体获取碰撞体组件 myCol = GetComponent <Collider2D>(); //我的渲染器获取组件 myRender = GetComponent <SpriteRenderer>(); //现有HP为最大血量 CurrentHp = maxHp; //现有武器 实例 新的枪的开火点—— 为何要这样实例化 用处是? currentWeapon = new Gun(firePoint, isPlayerSide); }
//void UpdateWeaponProperties(GameObject weaponToUpdate, GameObject oldWeaponProperties) //{ // weaponToUpdate.GetComponent<WeaponProperties>().UpdateAllVariables(oldWeaponProperties.GetComponent<WeaponProperties>()); //} //void UpdateWeaponProperties(GameObject weaponToUpdate, WeaponProperties oldWeaponProperties) //{ // WeaponProperties newProperties = weaponToUpdate.GetComponent<WeaponProperties>(); // newProperties.UpdateAllVariables(oldWeaponProperties); //} public void IncreaseMaxWeaponsByOne() { weaponSwitch.maxWeapons += 1; int equippedWeaponsLength = equippedWeapons.Length; Weapon1[] tempArray = new Weapon1[equippedWeaponsLength]; for (int i = 0; i < equippedWeaponsLength; i++) { tempArray[i] = equippedWeapons[i]; } equippedWeapons = new Weapon1[equippedWeaponsLength + 1]; for (int i = 0; i < equippedWeaponsLength; i++) { equippedWeapons[i] = tempArray[i]; } equippedWeapons[equippedWeaponsLength + 1] = new Weapon1(); }
void Start() { // Gather a list of weapons and their type names pulled from the weapontype table List <Weapon1> weapons = dbManager.Query <Weapon1>( "SELECT " + "W.WeaponID, " + "W.WeaponName, " + "W.Damage, " + "W.Cost, " + "W.Weight, " + "W.WeaponTypeID, " + "T.Description AS WeaponTypeDescription " + "FROM " + "Weapon W " + "JOIN WeaponType T " + "ON W.WeaponTypeID = T.WeaponTypeID " + "ORDER BY " + "W.WeaponID " ); // output the list of weapons outputText.text = "Weapons\n\n"; foreach (Weapon1 weapon in weapons) { outputText.text += "Name: '" + weapon.WeaponName + "' " + "Damage:" + weapon.Damage.ToString() + " " + "Cost:" + weapon.Cost.ToString() + " " + "Weight:" + weapon.Weight.ToString() + " " + "Type:" + weapon.WeaponTypeDescription + "\n"; } // get the first weapon record that has a WeaponID > 4 outputText.text += "\nFirst weapon record where the WeaponID > 4: "; bool recordExists; Weapon1 firstWeapon = dbManager.QueryFirstRecord <Weapon1>(out recordExists, "SELECT WeaponName FROM Weapon WHERE WeaponID > 4"); if (recordExists) { outputText.text += firstWeapon.WeaponName + "\n"; } else { outputText.text += "No record found\n"; } }
void UpdateEquippedWeapons() { weaponSwitch.UpdateEquippedWeapons(); if (weaponSlot.childCount < 1) { for (int i = 0; i < equippedWeapons.Length; i++) { equippedWeapons[i] = new Weapon1(); } } else { for (int i = 0; i < weaponSwitch.equippedWeapons.Length; i++) { equippedWeapons[i].name = weaponSwitch.equippedWeapons[i].name; equippedWeapons[i].weapon = weaponSwitch.equippedWeapons[i].weapon; equippedWeapons[i].ammo = weaponSwitch.equippedWeapons[i].ammo; } } }
public override void Update(double dt) { Weapon1.Owner = this; Weapon2.Owner = this; base.Update(dt); t += SwingSpeed * dt; double vx = 0, vy = 0; if (Key.A.Pressed()) { vx -= 1; } if (Key.D.Pressed()) { vx += 1; } if (Key.W.Pressed()) { vy += 1; } if (Key.S.Pressed()) { vy -= 1; } if (MouseButton.Left.Pressed()) { Weapon1.Shoot(World.Current.cam.FromWH(Mouse.Position, App.Width, App.Height)); } if (MouseButton.Right.Pressed()) { Weapon2.Shoot(World.Current.cam.FromWH(Mouse.Position, App.Width, App.Height)); } var targetVel = new Vec2(vx, vy).Unit *Speed; Velocity += Vec2.Clamp(targetVel - Velocity, Accel * dt); Weapon2.Update(dt); Weapon1.Update(dt); }
///<inheritdoc/> public override int GetHashCode() { int hash = 17; // Overflow is fine, just wrap unchecked { hash = (hash * 29) + PaintScheme.GetHashCode(); hash = (hash * 29) + Health.GetHashCode(); hash = (hash * 29) + Compliance.GetHashCode(); hash = (hash * 29) + FlashLights.GetHashCode(); hash = (hash * 29) + LifeFormState.GetHashCode(); hash = (hash * 29) + FrozenStatus.GetHashCode(); hash = (hash * 29) + State.GetHashCode(); hash = (hash * 29) + Weapon1.GetHashCode(); hash = (hash * 29) + Weapon2.GetHashCode(); hash = (hash * 29) + CamouflageType.GetHashCode(); hash = (hash * 29) + ConcealedStationary.GetHashCode(); hash = (hash * 29) + ConcealedMovement.GetHashCode(); } return(hash); }
public void SpawnWeapons(Node mainNode, Node camera) { if (Weapon1 != null) { Weapon1.Spawn(camera, "Weapon1"); } if (Weapon2 != null) { Weapon2.Spawn(camera, "Weapon2"); } if (Weapon3 != null) { Weapon3.Spawn(camera, "Weapon3"); } if (Weapon4 != null) { Weapon4.Spawn(camera, "Weapon4"); } HandGrenadeManager.MainNode = mainNode; }
public void Delete() { float delay = 0.3f * HexGrid.GameSpeed; foundationPart = null; if (weapon1 != null) { HexGrid.Destroy(weapon1.gameObject, delay); weapon1 = null; } if (extractor1 != null) { HexGrid.Destroy(extractor1.gameObject, delay); extractor1 = null; } if (container != null) { HexGrid.Destroy(container.gameObject, delay); container = null; } if (assembler != null) { HexGrid.Destroy(assembler.gameObject, delay); assembler = null; } if (reactor1 != null) { HexGrid.Destroy(reactor1.gameObject, delay); reactor1 = null; } if (engine1 != null) { HexGrid.Destroy(engine1.gameObject, delay); engine1 = null; } }
public void Assemble() { MoveUpdateStats stats = MoveUpdateStats; if (stats == null) { return; } if (currentPos == null) { return; } /* * NextMove.Stats.EngineLevel * NextMove.Stats.ArmorLevel ** * NextMove.Stats.ContainerLevel * NextMove.Stats.ExtractorLevel * NextMove.Stats.WeaponLevel * NextMove.Stats.ReactorLevel * NextMove.Stats.ProductionLevel */ HexCell targetCell = HexGrid.GroundCells[currentPos]; // Place the engine if (stats.EngineLevel > 0) { if (engine1 == null && stats.EngineLevel == 1) { engine1 = HexGrid.InstantiatePrefab <Engine1>("Engine1"); engine1.UnitFrame = this; engine1.UnitId = UnitId; engine1.name = UnitId + "-Engine"; foundationPart = engine1; SetPlayerColor(playerId, engine1.gameObject); unitLayout.PlaceOnGround(engine1, targetCell, HexGrid); } } else { if (foundationPart != null && engine1 == foundationPart) { ReparentParts(); foundationPart = null; } if (engine1 != null) { HexGrid.Destroy(engine1.gameObject); engine1 = null; } } // Place big extractor if (stats.ExtractorLevel > 0) { if (extractor1 == null && stats.ExtractorLevel == 1) { if (foundationPart == null) { extractor1 = HexGrid.InstantiatePrefab <Extractor1>("ExtractorGround1"); unitLayout.PlaceOnGround(extractor1, targetCell, HexGrid); foundationPart = extractor1; extractor1.name = UnitId + "-Extractor"; extractor1.UnitFrame = this; SetPlayerColor(playerId, extractor1.gameObject); } } } else { if (foundationPart != null && extractor1 == foundationPart) { ReparentParts(); foundationPart = null; } if (extractor1 != null) { HexGrid.Destroy(extractor1.gameObject); extractor1 = null; } } if (stats.ProductionLevel > 0) { if (assembler == null || assembler.Level != stats.ProductionLevel) { if (assembler != null) { HexGrid.Destroy(assembler.gameObject); assembler = null; } assembler = HexGrid.InstantiatePrefab <Assembler1>("Assembler" + stats.ProductionLevel); assembler.UnitFrame = this; assembler.Level = stats.ProductionLevel; assembler.name = UnitId + "-Assembler"; SetPlayerColor(playerId, assembler.gameObject); if (foundationPart == null) { unitLayout.PlaceOnGround(assembler, targetCell, HexGrid); foundationPart = assembler; } else { if (unitLayout.frame1 != null) { HexGrid.Destroy(unitLayout.frame1.gameObject); unitLayout.frame1 = null; } unitLayout.PlaceBigPart(assembler, foundationPart, targetCell, HexGrid); } } } else { if (assembler != null) { HexGrid.Destroy(assembler.gameObject); assembler = null; } } if (stats.ContainerLevel > 0) { if (container == null || container.Level != stats.ContainerLevel) { if (container != null) { HexGrid.Destroy(container.gameObject); container = null; } container = HexGrid.InstantiatePrefab <Container1>("Container" + stats.ContainerLevel); container.UnitFrame = this; container.name = UnitId + "-Container"; container.Level = stats.ContainerLevel; SetPlayerColor(playerId, container.gameObject); if (foundationPart is Extractor1) { if (stats.ProductionLevel > 0) { // Put it on top of the assembler unitLayout.PlaceOnTop(container, foundationPart, targetCell, HexGrid, 0.6f); } else { unitLayout.PlaceOnTop(container, foundationPart, targetCell, HexGrid, 0.3f); } } else { if (foundationPart == null) { unitLayout.PlaceOnGround(container, targetCell, HexGrid); foundationPart = container; } else { // Blueprint if (!unitLayout.PlaceContainer(container, foundationPart, targetCell, HexGrid)) { } //unitLayout.PlacePart(container, foundationPart, targetCell, HexGrid); } } } container.UpdateContent(stats.ContainerFull); } else { if (container != null) { HexGrid.Destroy(container.gameObject); container = null; } } if (stats.ReactorLevel > 0) { if (reactor1 == null && stats.ReactorLevel == 1) { reactor1 = HexGrid.InstantiatePrefab <Reactor1>("Reactor1"); reactor1.UnitFrame = this; reactor1.name = UnitId + "-Reactor1"; SetPlayerColor(playerId, reactor1.gameObject); if (foundationPart is Extractor1) { if (stats.ProductionLevel > 0 && stats.ContainerLevel > 0) { // Put it on top of the container unitLayout.PlaceOnTop(reactor1, foundationPart, targetCell, HexGrid, 0.8f); } else { unitLayout.PlaceBigPart(reactor1, foundationPart, targetCell, HexGrid); } } else { if (foundationPart == null) { unitLayout.PlaceOnGround(reactor1, targetCell, HexGrid); foundationPart = reactor1; } else { unitLayout.PlacePart(reactor1, foundationPart, targetCell, HexGrid); } } } } else { if (reactor1 != null) { HexGrid.Destroy(reactor1.gameObject); reactor1 = null; } } if (stats.WeaponLevel > 0) { if (weapon1 == null && stats.WeaponLevel == 1) { weapon1 = HexGrid.InstantiatePrefab <Weapon1>("Weapon1"); weapon1.UnitFrame = this; weapon1.name = UnitId + "-Weapon"; SetPlayerColor(playerId, weapon1.gameObject); if (foundationPart == null) { unitLayout.PlaceOnGround(weapon1, targetCell, HexGrid); foundationPart = weapon1; } else if (foundationPart is Extractor1) { unitLayout.PlaceBigPart(weapon1, foundationPart, targetCell, HexGrid); } else { if (!unitLayout.PlaceWeapon(weapon1, foundationPart, targetCell, HexGrid)) { } } } weapon1.UpdateContent(stats.WeaponLoaded); } else { if (weapon1 != null) { HexGrid.Destroy(weapon1.gameObject); weapon1 = null; } } // Place small extractor if (stats.ExtractorLevel > 0) { if (extractor1 == null && stats.ExtractorLevel == 1) { if (foundationPart != null) { extractor1 = HexGrid.InstantiatePrefab <Extractor1>("Extractor1"); unitLayout.PlacePart(extractor1, foundationPart, targetCell, HexGrid); extractor1.name = UnitId + "-Extractor"; extractor1.UnitFrame = this; SetPlayerColor(playerId, extractor1.gameObject); } } } }