Esempio n. 1
0
 private void onWeaponChanged(GameObject o, Weapon.WeaponData previous, Weapon.WeaponData current)
 {
     if (previous != null)
     {
         if (previous.param.type == Weapon.Type.SMG)
         {
             previous.param.reload *= SMG_BONUS;
             unit.speed            /= SMG_BONUS;
         }
         else if (previous.param.type == Weapon.Type.PISTOL)
         {
             previous.param.reload *= PISTOL_BONUS;
             previous.param.aim    *= PISTOL_AIM_BONUS;
             unit.speed            /= PISTOL_BONUS;
         }
     }
     if (current != null)
     {
         if (current.param.type == Weapon.Type.SMG)
         {
             current.param.reload /= SMG_BONUS;
             unit.speed           *= SMG_BONUS;
         }
         else if (current.param.type == Weapon.Type.PISTOL)
         {
             current.param.reload /= PISTOL_BONUS;
             current.param.aim    /= PISTOL_AIM_BONUS;
             unit.speed           *= PISTOL_BONUS;
         }
     }
 }
Esempio n. 2
0
    override public void init(GameObject cst, object param = null)
    {
        base.init(cst, param);
        Soldier soldier = caster.GetComponent <Soldier>();

        grenade = soldier.grenade;
    }
Esempio n. 3
0
    public void setWeapon(Weapon.WeaponData wd)
    {
        Debug.Assert(wd != null && wd.param != null, "[WeaponPickup] Attempt to set a null weapon to pickup.");
        wdata = wd;

        spriteRenderer.sprite = sprites[wdata.param.sprite];
    }
Esempio n. 4
0
 public bool takeWeapon(Weapon.WeaponData wdata)
 {
     if (weapons[wdata.param.category] != null)
     {
         return(false);
     }
     weapons[wdata.param.category] = wdata;
     return(true);
 }
Esempio n. 5
0
 public bool switchSecondary()
 {
     Weapon.WeaponData wdata = weapons[wIndex];
     if (wdata == null || wdata.secondary == null)
     {
         return(false);
     }
     weapon.weapon = weapon.weapon == wdata ? wdata.secondary : wdata;
     return(true);
 }
Esempio n. 6
0
 void Start()
 {
     animator = GetComponent <Animator> ();
     weapon   = GetComponent <Weapon> ();
     for (int i = 0; i < weapons.Length; i++)
     {
         Weapon.WeaponData wdata = weapons[i];
         wdata.init();
         wdata.applyAtachments();
     }
     weaponIndex = 0;
 }
Esempio n. 7
0
        private void LoadWeapons()
        {
            Weapons = new Dictionary <string, Weapon.WeaponData>();

            XmlDocument gamedata = Resource.GetXmlFromResource("data.weapons.xml", Assembly);

            foreach (XmlNode node in gamedata.SelectNodes("/weapons/weapon"))
            {
                Weapon.WeaponData weapon = new Weapon.WeaponData(node, Lua);

                Weapons.Add(weapon.ID, weapon);
            }
        }
Esempio n. 8
0
 override public void init(GameObject cst, object param = null)
 {
     base.init(cst, param);
     switch_to = soldier.weaponIndex;
     for (int i = 0; i < soldier.weapons.Length; i++)
     {
         Weapon.WeaponData wdata = soldier.weapons[i];
         if (soldier.weaponIndex != i && wdata != null && (wdata.ammo > 0 || wdata.clip > 0))
         {
             switch_to = i;
             break;
         }
     }
 }
Esempio n. 9
0
    public Weapon.WeaponData getGun()
    {
        Weapon.WeaponData data = new Weapon.WeaponData(guns[gunDD.value]);
        List <string>     list = new List <string>();

        if (scopeDD.value != 0)
        {
            list.Add(getAttachment(Attachment.SCOPE));
        }
        if (undersulgDD.value != 0)
        {
            list.Add(getAttachment(Attachment.UNDERSLUG));
        }
        data.attachments = list.ToArray();
        return(data);
    }
Esempio n. 10
0
 public void setWeapons(Weapon.WeaponData[] value)
 {
     for (int i = 0; i < weapons.Length; i++)
     {
         Weapon.WeaponData wdata = weapons[i];
         wdata.removeAtachments();
     }
     weapons = value;
     for (int i = 0; i < weapons.Length; i++)
     {
         Weapon.WeaponData wdata = weapons[i];
         wdata.init();
         wdata.applyAtachments();
     }
     wIndex      = -1;
     weaponIndex = 0;
 }
Esempio n. 11
0
	override public void onAnimation(int param = 0) {
		AnimatorStateInfo info = animator.GetCurrentAnimatorStateInfo(0);
		if (animState != info.shortNameHash)
			return;
		if(param == 1) {
			Soldier soldier = caster.GetComponent<Soldier>();
			Weapon.WeaponData wdata = soldier.melee;
			Collider[] hitColliders = Physics.OverlapSphere(caster.transform.position, RANGE*10, 1, QueryTriggerInteraction.Ignore);
			foreach (Collider collider in hitColliders) {
				GameObject other = collider.gameObject;
				Unit unit = other.GetComponent<Unit>();
				Health health = other.GetComponent<Health>();
				if (unit != null && health != null && other != caster && Quaternion.Angle(caster.transform.rotation, Quaternion.LookRotation(other.transform.position - caster.transform.position)) <= ANGLE) {
					Damage damage = wdata.getDamage(caster);
					health.receiveDamage(damage.getDamageValue(0, 0));
				}
			}
		} else {
			complete();
		}
	}
Esempio n. 12
0
 override public void add(Weapon.WeaponData wdata)
 {
     wdata.secondary = new Weapon.WeaponData("M870MCS");
 }
Esempio n. 13
0
 virtual public void add(Weapon.WeaponData wdata)
 {
 }
Esempio n. 14
0
 virtual public void remove(Weapon.WeaponData wdata)
 {
 }
Esempio n. 15
0
 override public void add(Weapon.WeaponData wdata)
 {
     wdata.param.aim         *= AIM;
     wdata.param.aimFallTurn *= AIM_TURN;
     wdata.param.aimFallWalk *= AIM_WALK;
 }
Esempio n. 16
0
 override public void remove(Weapon.WeaponData wdata)
 {
     wdata.param.aim         /= AIM;
     wdata.param.aimFallTurn /= AIM_TURN;
     wdata.param.aimFallWalk /= AIM_WALK;
 }
Esempio n. 17
0
 override public void remove(Weapon.WeaponData wdata)
 {
     wdata.secondary = null;
 }