void Ammo(Collider col) { wepInv = col.gameObject.GetComponentInChildren<WeaponInventory>(); if(wepInv.GetCurAmmo() <= wepInv.GetMaxAmmo()-1 ) { wepInv.AddAmmo(20); Destroy(gameObject); } }
private void Start() { //make sure the enemy contains at least one ai logic if (GetComponents<AILogicBase>().Length == 0) { Debug.LogError("No AILogicBase component can be found on enemy gameobject (" + name + ")"); } Transform weapon_obj = transform.parent.FindChild("weapon"); if (weapon_obj == null) Debug.LogError("'weapon' object cannot be found in enemy parent's children"); weapon_inventory = weapon_obj.GetComponent<WeaponInventory>(); weapon_inventory.init(this); weapon_control = weapon_obj.GetComponent<EnemyWeaponControl>(); weapon_control.init(this); health = GetComponent<GenericHealth>(); health.init(this); }
public void init() { pos = Map.grid.grid_to_world(Map.grid.world_to_grid(transform.position)); current_node = Map.grid.get_node(Map.grid.world_to_grid(pos)); controller = GetComponent<Controller2D>(); controller.init(); player_movement = GetComponent<PlayerMovement>(); player_movement.init(); Transform weapon_obj = transform.parent.FindChild("weapon_base"); if (weapon_obj == null) Debug.LogError("'weapon_base' object cannot be found in player parent's children"); inventory = weapon_obj.GetComponent<WeaponInventory>(); inventory.init(this); weapon_control = weapon_obj.GetComponent<PlayerWeaponControl>(); weapon_control.init(); grappling_hook = GetComponent<GrapplingHook>(); grappling_hook.init(); health = GetComponent<GenericHealth>(); health.init(this); }
public void update(WeaponInventory inventory) { int i = inventory.equipped_id - 1; while (true) { if (i < 0) i = inventory.weapons.Count - 1; if (inventory.weapons[i].active) { slot_left.GetComponent<Image>().sprite = weapon_images[i]; break; } if (i == inventory.equipped_id) break; --i; } GetComponent<Image>().sprite = weapon_images[inventory.equipped_id]; i = inventory.equipped_id + 1; while (true) { if (i >= inventory.weapons.Count) i = 0; if (inventory.weapons[i].active) { slot_right.GetComponent<Image>().sprite = weapon_images[i]; break; } if (i == inventory.equipped_id) break; ++i; } }
protected override void OnEquip(WeaponInventory inv) { this.ammoPerKill = this.tables.ammoPerKill.get(this.weaponClass).Value; this.stats = inv.GetComponent <PlayerBase>().stats; }
protected virtual void OnEquip(WeaponInventory inv) { }
public void init(Enemy parent) { this.parent = parent; inventory = GetComponent<WeaponInventory>(); }
private SelectedWeapon(HudComponentDefinition definition, WeaponInventory weaponInventory, float scale) : base(definition) { WeaponInventory = weaponInventory; Scale = new Vector2(scale, scale); }
protected override void OnEquip(WeaponInventory inv) { this.staminaCost = this.tables.staminaCost.get(this.weaponClass).Value; stats = inv.GetComponent <PlayerBase>().stats; }
public void OnEquip(WeaponInventory inv, WeaponTables tables, WeaponFactory.CLASS weaponClass) { this.weaponClass = weaponClass; this.tables = tables; this.OnEquip(inv); }
protected override void OnEquip(WeaponInventory inv) { this.cooldownLength = this.tables.coolDown.get(this.weaponClass).Value; cooldownEnd = Time.time; }
// Use this for initialization void Start() { weaponinventoryScript = GameObject.FindGameObjectWithTag("Canvas2").GetComponent <WeaponInventory>(); weapons = new GameObject[2]; //weapons[0] = gameObject.transform.GetChild(0).gameObject; //weapons[1] = gameObject.transform.GetChild(1).gameObject; weaponZero = gameObject.transform.GetChild(0).gameObject; weaponOne = gameObject.transform.GetChild(1).gameObject; pickaxe = GameObject.Find("pickaxe"); //replaceWeaponScript = // count = 0; // foreach (Transform i in gameObject.transform) // { // count++; // } // weapons = new GameObject[count]; // count = 0; // foreach (Transform i in gameObject.transform) // { // weaponsList.Add(i.gameObject); // weapons[count] = i.gameObject; // count++; // } // count = 0; // foreach (GameObject i in weapons) // { // count++; // if(count > 2) // { // count = 2; // } // } // availableWeapons = new GameObject[count]; // count = 0; // foreach (GameObject i in weapons) // { // availableWeapons[count] = i.gameObject; // count++; // } //weapons[1].SetActive(false); rend1 = weaponOne.GetComponentsInChildren <Renderer>(); foreach (Renderer obj in rend1) { obj.enabled = false; } //weapons[1].GetComponentsInChildren<Renderer>().enabled = false; weaponOne.GetComponent <Collider>().enabled = false; weaponOne.GetComponent <Animator>().enabled = false; weaponZeroActive = true; weaponOneActive = false; fixSlot1 = false; SwitchToPickaxe(); }
public void init() { parent = Entities.player; inventory = GetComponent<WeaponInventory>(); }
public void SwitchMainWeapons() { if (pickaxeActive) { weaponZero = gameObject.transform.GetChild(0).gameObject; weaponOne = gameObject.transform.GetChild(1).gameObject; weaponOne.transform.SetSiblingIndex(1); //weapons[1].SetActive(false); rendp = pickaxe.GetComponentsInChildren <Renderer>(); foreach (Renderer obj in rendp) { obj.enabled = false; } //weapons[1].GetComponentsInChildren<Renderer>().enabled = false; pickaxe.GetComponent <Collider>().enabled = false; pickaxe.GetComponent <Animator>().enabled = false; //weaponZero = gameObject.transform.GetChild(0).gameObject; //weaponOne = gameObject.transform.GetChild(1).gameObject; //weaponOneActive = false; //weaponZeroActive = true; pickaxeActive = false; rend0 = weaponZero.GetComponentsInChildren <Renderer>(); foreach (Renderer obj in rend0) { obj.enabled = true; } weaponZero.GetComponent <Collider>().enabled = true; weaponZero.GetComponent <Animator>().enabled = true; weaponZero.transform.SetAsFirstSibling(); weaponZero = gameObject.transform.GetChild(0).gameObject; weaponOne = gameObject.transform.GetChild(1).gameObject; weaponZeroActive = true; weaponOneActive = false; } if (weaponZeroActive) { weaponZero = gameObject.transform.GetChild(0).gameObject; weaponOne = gameObject.transform.GetChild(1).gameObject; //weapons[0].SetActive(false); weaponZero.transform.SetSiblingIndex(1); rend0 = weaponZero.GetComponentsInChildren <Renderer>(); foreach (Renderer obj in rend0) { obj.enabled = false; } //weapons[0].GetComponent<Renderer>().enabled = false; coll0 = weaponZero.GetComponentsInChildren <Collider>(); foreach (Collider col in coll0) { col.enabled = false; } weaponZero.GetComponent <Animator>().enabled = false; //weaponZero = gameObject.transform.GetChild(0).gameObject; //weaponOne = gameObject.transform.GetChild(1).gameObject; //weaponZeroActive = false; //weaponOneActive = true; rend1 = weaponOne.GetComponentsInChildren <Renderer>(); foreach (Renderer obj in rend1) { obj.enabled = true; } weaponOne.GetComponent <Collider>().enabled = true; weaponOne.GetComponent <Animator>().enabled = true; weaponOne.transform.SetAsFirstSibling(); weaponZero = gameObject.transform.GetChild(0).gameObject; weaponOne = gameObject.transform.GetChild(1).gameObject; weaponZeroActive = false; weaponOneActive = true; pickaxeActive = false; } //if (!weaponOneActive) //{ //weapons[1].SetActive(true); // rend1 = weaponOne.GetComponentsInChildren<Renderer>(); // foreach (Renderer obj in rend1) // { // obj.enabled = true; // } //weapons[1].GetComponent<Renderer>().enabled = true; // weaponOne.GetComponent<Collider>().enabled = true; // weaponOne.GetComponent<Animator>().enabled = true; // weaponOne.transform.SetAsFirstSibling(); // weaponZero = gameObject.transform.GetChild(0).gameObject; // weaponOne = gameObject.transform.GetChild(1).gameObject; // weaponOneActive = true; // } if (weaponOneActive) { weaponZero = gameObject.transform.GetChild(0).gameObject; weaponOne = gameObject.transform.GetChild(1).gameObject; weaponOne.transform.SetSiblingIndex(1); //weapons[1].SetActive(false); rend1 = weaponOne.GetComponentsInChildren <Renderer>(); foreach (Renderer obj in rend1) { obj.enabled = false; } //weapons[1].GetComponentsInChildren<Renderer>().enabled = false; coll1 = weaponOne.GetComponentsInChildren <Collider>(); foreach (Collider col in coll1) { col.enabled = false; } weaponOne.GetComponent <Animator>().enabled = false; //weaponZero = gameObject.transform.GetChild(0).gameObject; //weaponOne = gameObject.transform.GetChild(1).gameObject; //weaponOneActive = false; //weaponZeroActive = true; rend0 = weaponZero.GetComponentsInChildren <Renderer>(); foreach (Renderer obj in rend0) { obj.enabled = true; } weaponZero.GetComponent <Collider>().enabled = true; weaponZero.GetComponent <Animator>().enabled = true; weaponZero.transform.SetAsFirstSibling(); weaponZero = gameObject.transform.GetChild(0).gameObject; weaponOne = gameObject.transform.GetChild(1).gameObject; weaponZeroActive = true; weaponOneActive = false; pickaxeActive = false; } if (!weaponinventoryScript) { weaponinventoryScript = GameObject.FindGameObjectWithTag("Canvas2").GetComponent <WeaponInventory>(); } if (weaponinventoryScript) { if (weaponinventoryScript.wScreenActive) { weaponinventoryScript.CloseScreen(); weaponinventoryScript.OpenScreen(); } } }
public void init(Enemy parent) { this.parent = parent; inventory = GetComponent <WeaponInventory>(); }
// Use this for initialization void Start() { weaponInventory = GameObject.FindGameObjectWithTag("Player").GetComponentInChildren<WeaponInventory>(); }
void Start() { weaponInventory = this.transform.GetComponent <WeaponInventory>(); }
public virtual void OnUnequip(WeaponInventory inv) { }
void Start() { Instance = this; gameManager = GameManager.Instance; weaponInventory = GetComponent <WeaponInventory> (); }
private RemainingAmmo(HudComponentDefinition definition, Font font, string textTemplate, WeaponInventory weaponInventory) : base(definition) { Font = font; TextTemplate = textTemplate; WeaponInventory = weaponInventory; }