Esempio n. 1
0
        public Weapon EquipDefaultWeapon()
        {
            GenericWeapon dWeapon = defaultWeapon ? defaultWeapon : Resources.Load("Prefabs/Unarmed") as GenericWeapon;
            Weapon        weapon  = dWeapon.GenerateItem() as Weapon;

            return(weapon);
        }
            public void CacheWeaponUsed()
            {
                switch (TypeChoice.type)
                {
                case AttackType.MAINHAND_MELEE:
                    cachedWeaponUsed = actor.CharSheet.MainHand();
                    break;

                case AttackType.MAINHAND_RANGED:
                    cachedWeaponUsed = actor.CharSheet.MainHand();
                    break;

                case AttackType.OFFHAND_MELEE:
                    cachedWeaponUsed = actor.CharSheet.OffHand() as GenericWeapon;
                    break;

                case AttackType.OFFHAND_RANGED:
                    cachedWeaponUsed = actor.CharSheet.OffHand() as GenericWeapon;
                    break;

                default:
                    Debug.LogError("weapon used type was invalid");
                    cachedWeaponUsed = actor.CharSheet.MainHand();
                    break;
                }
            }
Esempio n. 3
0
        void UpdatePetDamage(GenericWeapon weapon)
        {
            var avg = (Strength - 20) / 2;

            weapon.Damages[0].Minimum = avg - avg / 5;
            weapon.Damages[0].Maximum = avg + avg / 5;
        }
Esempio n. 4
0
    public void HandleAnimationEvent(AnimationEventType type, string animationName)
    {
        if (!attacking)
        {
            return;
        }
        switch (type)
        {
        case AnimationEventType.ATTACK_SWING_MOMENT:
//			if (lastAttack.TypeChoice.IsRanged () & lastAttack.WeaponUsed.IsThrown ()) {
//				//nothing
//			} else {
            WeaponSwingFXType swingFx = lastAttack.WeaponUsed.SwingSoundFX;
            characterAudioSource.clip = SoundDispenser.instance.SwingFXFromType(swingFx);
            characterAudioSource.Play();
//			}
            break;

        case AnimationEventType.ATTACK_HIT_MOMENT:
            //this is where it should split off and launch the weapon if the attack was ranged
            if (lastAttack.TypeChoice.IsRanged())
            {
                GenericWeapon wp = lastAttack.WeaponUsed;
                GameObject    missileAnimPrefab = MissileAnimationPrefabDispenser.instance.GetAnimationPrefabByName(wp.MissileAnimationName);
                if (missileAnimPrefab != null)
                {
                    LaunchMissileAndSetup(missileAnimPrefab);
                }
                else
                {
                    AttackAnimationHitMoment();
                }
            }
            else
            {
                AttackAnimationHitMoment();
            }

            break;

        case AnimationEventType.LOOP:
            if (rangedAttacking)
            {
                animationTransform.Idle();
            }
            else
            {
                AttackAnimationEnded();
            }

            break;
        }
    }
Esempio n. 5
0
    public void LaunchMissileAndSetup(GameObject missilePrefab)
    {
        rangedAttacking = true;
        GameObject missileCopy = Instantiate(missilePrefab);

        missileCopy.transform.position = GetComponent <TileMovement> ().avatar.position;
        MissileScript missile = missileCopy.GetComponent <MissileScript> ();


        //this means miss
        if (lastAttack.resultingEffect == null)
        {
            List <ATTile> tiles = lastAttack.TargetActor().TileMovement.occupying.TilesWithinRange(1);
            missile.LaunchAt(tiles [Random.Range(0, tiles.Count)]);
        }
        else
        {
            missile.LaunchAt(lastAttack.TargetActor().TileMovement.occupying);
        }

//		UIManager.instance.cameraController.LockOn (missile.transform);

        GenericWeapon unequipped = lastAttack
                                   .actor
                                   .CharSheet
                                   .Unequip(lastAttack.WeaponUsed) as GenericWeapon;

        missile.OnConnectedWithTarget += (MissileScript self) => {
            AttackAnimationHitMoment();
            rangedAttacking = false;
            AttackAnimationEnded();
            if (lastAttack.TypeChoice.IsRanged() && lastAttack.WeaponUsed.IsThrown())
            {
                self.targetTile.AddItemToGround(unequipped);
            }
            //Add item to ground of the last tile hit.
        };

        missile.OnHitBlocker += (MissileScript self, ATTile blocker) => {
            lastAttack.resultingEffect = null;
            AttackAnimationHitMoment();
            rangedAttacking = false;
            AttackAnimationEnded();
            if (lastAttack.TypeChoice.IsRanged() && lastAttack.WeaponUsed.IsThrown())
            {
                self.previousHitTile.AddItemToGround(unequipped);
            }
            //Add item to ground of the player
        };

        lastMissileScript = missile;
    }
Esempio n. 6
0
 public void Start()
 {
     base.Start();
     speed        = UnityEngine.Random.Range(70, 120) / 100.0f; //TODO set human speed value
     weapon       = Weapons.GetWeapon(Weapons.Weapon.Gun);
     state        = States.Idle;
     target       = null;
     targetTag    = "zombie";
     healthPoints = 100;
     humanityRate = UnityEngine.Random.Range(40, 100);
     //Debug.Log("Just started as a " + gameObject.tag);
     StatusUpdater.humanCount++;
 }
Esempio n. 7
0
 public void Start()
 {
     base.Start();
     distanceToClosestSound = Mathf.Infinity;
     fistWeapon             = Weapons.GetWeapon(Weapons.Weapon.Fist);
     biteWeapon             = Weapons.GetWeapon(Weapons.Weapon.Bite);
     speed        = UnityEngine.Random.Range(40, 60) / 100.0f; //TODO set zombie speed value
     state        = States.Idle;
     target       = null;
     targetTag    = "human";
     healthPoints = 250;
     humanityRate = 0;
     //Debug.Log("Just started as a " + gameObject.tag);
     StatusUpdater.zombiesCount++;
 }
Esempio n. 8
0
 public void Start()
 {
     base.Start();
     distanceToClosestSound = Mathf.Infinity;
     fistWeapon = Weapons.GetWeapon(Weapons.Weapon.Fist);
     biteWeapon = Weapons.GetWeapon(Weapons.Weapon.Bite);
     speed = UnityEngine.Random.Range(40,60)/100.0f; //TODO set zombie speed value
     state = States.Idle;
     target = null;
     targetTag = "human";
     healthPoints = 250;
     humanityRate = 0;
     //Debug.Log("Just started as a " + gameObject.tag);
     StatusUpdater.zombiesCount++;
 }
Esempio n. 9
0
 public void OnTriggerStay(Collider other)      //TODO create object collider
 {
     if (other.gameObject.CompareTag(targetTag))
     {
         float         distance   = Vector3.Distance(transform.position, other.attachedRigidbody.position);
         GenericWeapon usedWeapon = Attack(distance, other.attachedRigidbody);
         GenericAgent  otherAgent = other.gameObject.GetComponent <GenericAgent>();
         if ((usedWeapon != null) && (otherAgent != null))
         {
             if (usedWeapon.Contagion > 0)
             {
                 otherAgent.humanityRate -= usedWeapon.Contagion;
             }
             otherAgent.healthPoints -= usedWeapon.Damages;
         }
     }
 }
    IEnumerator ReallySync(PaperDoll pd)
    {
        yield return(new WaitForEndOfFrame());

        foreach (EquipmentAnimatorMapping mapping in animators)
        {
            Equipment equipped = null;
//			Debug.Log ("Syncing " + mapping.type + " animation " + " pd slots size: " + pd.slots.Count);
            if (pd.slots.TryGetValue(mapping.type, out equipped))
            {
//				if (equipped == null)
//					Debug.LogError ("equipped is null for  " + mapping.type);
//				else
//					Debug.Log ("equipped is not null for " + mapping.type + ". YAY!");
                if (equipped is GenericWeapon && mapping.type == EquipmentSlotType.OFF_HAND)
                {
                    GenericWeapon wep = equipped as GenericWeapon;
                    ChangeOutAnimation(mapping.type, wep.OffhandAnimationControllerName);
                }
                else
                {
                    ChangeOutAnimation(mapping.type, equipped.AnimationControllerName);
                }
            }
            else
            {
                ClearAnimation(mapping.type);
            }
        }

        if (GetComponent <AT.Battle.Actor> ().CharSheet.race != null)          //can be null in some test apps.
//			Debug.Log("SYCNGIL!: " + GetComponent<AT.Battle.Actor> ().CharSheet.race.BodyAnimationOverride);
        {
            ChangeOutAnimation(EquipmentSlotType.BODY_OVERRIDE, GetComponent <AT.Battle.Actor> ().CharSheet.race.BodyAnimationOverride);
        }
        else
        {
            Debug.LogWarning(GetComponent <AT.Battle.Actor> ().CharSheet.Name + " has no race.  Are you just testing something? ");
        }

        syncing = false;
    }
        public override List <IActionOptionChoice> GetChoicesUnfiltered(Actor actor, Action attack)
        {
            //return attack type choices....
            List <IActionOptionChoice> ret = new List <IActionOptionChoice>();
            GenericWeapon mainhand         = actor.CharSheet.MainHand();
            Equipment     offhand          = actor.CharSheet.OffHand();

            if (!mainhand.IsRanged())
            {
                ret.Add(new AttackTypeChoice(AttackType.MAINHAND_MELEE, actor.CharSheet.MainHand()));
            }


            if (mainhand.IsThrown() || mainhand.IsRanged())
            {
                ret.Add(new AttackTypeChoice(AttackType.MAINHAND_RANGED, actor.CharSheet.MainHand()));
            }


            if (offhand != null && offhand is GenericWeapon && !(offhand as GenericWeapon).IsRanged())
            {
                ret.Add(new AttackTypeChoice(AttackType.OFFHAND_MELEE, actor.CharSheet.OffHand() as GenericWeapon));
            }

            if (offhand is GenericWeapon)
            {
                GenericWeapon wep = offhand  as GenericWeapon;
                if (wep.IsThrown() || wep.IsRanged())
                {
                    ret.Add(new AttackTypeChoice(AttackType.OFFHAND_RANGED, offhand as GenericWeapon));
                }
            }

            if (ret.Count == 0)
            {
                lastReasonForNoChoices = "No weapons available for attacking.  Really there should always be an option for fist?";
            }

            return(ret);
        }
Esempio n. 12
0
    public void GenerateWeapon()
    {
        weaponType = weaponTypes[Random.Range(0, weaponTypes.Length)];
        weaponLVL  = Random.Range(weaponLVLMin, weaponLVLMax + 1);

        GetModules(weaponType, weaponLVL);

        GameObject baseObject = Instantiate(weaponModuleBase.gameObject, trsf.position, trsf.rotation) as GameObject;
        Transform  bTransform = baseObject.transform;

        Instantiate(weaponModuleCannon.gameObject, bTransform.position, bTransform.rotation, bTransform);
        Instantiate(weaponModuleMagazine.gameObject, bTransform.position, bTransform.rotation, bTransform);

        GenericWeapon gw = baseObject.GetComponent <GenericWeapon>();

        gw.SetUpItem();

        float dps = gw.dps;

        baseObject.name = weaponModuleMagazine.data.projectileType.ToString() + " LVL " + weaponLVL
                          + "(B" + weaponModuleBase.data.moduleLevel + "C" + weaponModuleCannon.data.moduleLevel + "M" + weaponModuleMagazine.data.moduleLevel
                          + ") X" + weaponModuleCannon.cannons.Length + " (" + dps.ToString("F1") + "dps)";
    }
Esempio n. 13
0
 public void Start()
 {
     base.Start();
     speed = UnityEngine.Random.Range(70, 120 ) / 100.0f;  //TODO set human speed value
     weapon = Weapons.GetWeapon(Weapons.Weapon.Gun);
     state = States.Idle;
     target = null;
     targetTag = "zombie";
     healthPoints = 100;
     humanityRate = UnityEngine.Random.Range(40, 100);
     //Debug.Log("Just started as a " + gameObject.tag);
     StatusUpdater.humanCount++;
 }
 public AttackTypeChoice(AttackType type, GenericWeapon w)
 {
     this.type   = type;
     this.weapon = w;
 }
Esempio n. 15
0
 public void SetWeaponUsed(GenericWeapon w)
 {
     weaponUsed = w;
 }
Esempio n. 16
0
 private void OnEnable()
 {
     thisGunTransform = thisGunGO.transform;
     thisGun          = thisGunGO.GetComponent <GenericWeapon>();
     timeForNextFire  = Time.time + thisGun.fireRate;
 }
Esempio n. 17
0
 public void SetWeapon(GenericWeapon weapon)
 {
     CurrentWeapon = weapon;
     //Debug.Log("seweapon" + CurrentWeapon.Damage);
 }
Esempio n. 18
0
    public TestSerialization() : base()
    {
        Test("That can serialize inventory items safely and correctly", () => {
            Sheet c = new Sheet();

            Assert(c.inventory != null);
            c.inventory.items[0] = new GenericArmour(EquipmentSubtype.ARMOUR_CHAINMAIL);

            c.inventory.items[1] = new GenericWeapon(EquipmentSubtype.SIMPLE_DAGGER);
            Manager.Serialize(c, TestPath);

            Sheet after = Manager.Deserialize <Sheet>(TestPath);
            Assert(after.inventory != null);
            Assert(after.inventory.items != null);
            GenericArmour arm = after.inventory.items[0] as GenericArmour;
            GenericWeapon wep = after.inventory.items[1] as GenericWeapon;
            Assert(arm.Subtype == EquipmentSubtype.ARMOUR_CHAINMAIL);
            Assert(wep.Subtype == EquipmentSubtype.SIMPLE_DAGGER);
        });

        Test("That CanSerializeAFeatureFromAndToSubclass", () => {
            //create a subclass instance of a feature
            PerLevelHitPoints flhp = new PerLevelHitPoints(10, ClassType.FIGHTER);


            string path = Application.persistentDataPath + Path.DirectorySeparatorChar + "test123";

            Manager.Serialize(flhp, path);


            //System.Type t = System.Type.GetType ("AT.Characters.FirstLevelHitPointsWrapper");

            GenericFeature f = Manager.Deserialize <GenericFeature> (path);

            File.Delete(path);


            Sheet c    = new Sheet();
            int before = c.HitPoints;
            f.WhenActivatedOn(c);
            Assert(c.HitPoints != before);


            //create a subclass instance of a feature
            GaugeMod ability = new GaugeMod("dexterity", 10, "bullshit", true);
            Manager.Serialize(ability, TestPath);


            //System.Type t = System.Type.GetType ("AT.Characters.FirstLevelHitPointsWrapper");

            GenericFeature hamburgerFlip = Manager.Deserialize <GenericFeature> (TestPath);

            //		Debug.Log ("hf: " + hamburgerFlip.GetType());

            File.Delete(path);


            GaugeMod ab = (GaugeMod)hamburgerFlip;

            Assert(ab.isBase);


            Sheet cheese = new Sheet();
            int before1  = cheese.Dexterity;

            ab.WhenActivatedOn(cheese);
            //		Debug.Log ("prop aft" + cheese.GaugeByName("dexterity").ModifiedCurrent);
            Assert(cheese.Dexterity != before1);
        });

        Test("that CanSerializeFeatureBundle", () => {
            ClassLevel5e fb = new ClassLevel5e(ClassType.CLERIC, 0);
            fb.features.Add(new PerLevelHitPoints(10, ClassType.FIGHTER));
            fb.features.Add(new PerLevelHitPoints(4, ClassType.CLERIC));
            fb.features.Add(new PerLevelHitPoints(1, ClassType.ROGUE));


            string path = Application.persistentDataPath + Path.DirectorySeparatorChar + "Test";
            Manager.Serialize(fb, path);

            ClassLevel5e unse = Manager.Deserialize <ClassLevel5e> (path);
            File.Delete(path);

            Assert(unse.classType == fb.classType);

            for (int i = 0; i < fb.features.Count; i++)
            {
                PerLevelHitPoints before = (PerLevelHitPoints)fb.features [i];
                PerLevelHitPoints after  = (PerLevelHitPoints)unse.features [i];
                Assert(before.amount == after.amount);
            }
        });

        Test("that CanSerializeWeapon", () => {
            GenericWeapon sword = new Longsword();
            Manager.Serialize(sword, TestPath);


            GenericWeapon after = Manager.Deserialize <GenericWeapon> (TestPath);
            File.Delete(TestPath);


            Assert(after.Dice[0] == sword.Dice[0]);
            Assert(after.DamageType == sword.DamageType);
            Assert(after.Subtype == sword.Subtype);
            Assert(after.Type == sword.Type);
            //after.WhenEquipped (new Sheet ());
        });

        Test("that CanSerializeArmour", () => {
            GenericArmour armour = new PaddedArmour();

            Manager.Serialize(armour, TestPath);


            GenericArmour after = Manager.Deserialize <GenericArmour> (TestPath);
            File.Delete(TestPath);

            Assert(armour.BaseAc == after.BaseAc);
            Assert(armour.Subtype == after.Subtype);
            Assert(armour.Type == after.Type);
        });

        Test("that CanSerializePaperDoll", () => {
            PaperDoll pd = new PaperDoll();

            pd.slots.Add(EquipmentSlotType.BODY, new PaddedArmour());
            pd.slots.Add(EquipmentSlotType.MAIN_HAND, new Longsword());
            pd.slots.Add(EquipmentSlotType.OFF_HAND, new Dagger());

            Manager.Serialize(pd, TestPath);


            PaperDoll after = Manager.Deserialize <PaperDoll> (TestPath);
            File.Delete(TestPath);

            Assert(after.slots.Count == after.slots.Count);
        });

        Test("that CanSerializeGauge", () => {
            Gauge g = new Gauge("hello");
            Manager.Serialize(g, TestPath);

            Gauge after = Manager.Deserialize <Gauge> (TestPath);
            File.Delete(TestPath);


            Assert(after.ModifiedCurrent == g.ModifiedCurrent);
            Assert(after.ModifiedMax == g.ModifiedMax);
            Assert(after.Name == g.Name);
        });

        Test("that CanSerializeRace", () => {
            Race r = new Race(RaceName.TIEFLING);

            Manager.Serialize(r, TestPath);

            Race after = Manager.Deserialize <Race> (TestPath);

            Assert(after.name == r.name);

            Assert(after.speed.ModifiedCurrent == r.speed.ModifiedCurrent);

            int i = 0;

            foreach (GenericFeature f in after.features)
            {
                Assert(f.Name() == r.features [i].Name());
                i++;
            }
        });

        Test("that CanSerializeSheet", () => {
            Sheet c           = new Sheet();
            c.race            = new Race(RaceName.TIEFLING);
            ClassLevel5e lvl1 = new ClassLevel5e(ClassType.FIGHTER, 0);
            lvl1.features.Add(new FighterLevels.ArcheryFightingStyle());
            lvl1.features.Add(new FighterLevels.GreatWeaponFightingStyle());
            lvl1.features.Add(new FighterLevels.DuelingFightingStyle());
            lvl1.features.Add(new FighterLevels.DefenseFightingStyle());
            lvl1.features.Add(new FighterLevels.TwoWeaponFightingStyle());

            lvl1.InitDefaultFeatures();

            c.AddClassLevel(lvl1);

            c.ActivateFeatures();

            Manager.Serialize(c, TestPath);

            //c.DeactivateFeatures ();

            Sheet after = Manager.Deserialize <Sheet> (TestPath);

            after.ActivateFeatures();


            Debug.Log("rior " + c.HitPointsGauge.BaseModifierSum + ") " + c.HitPointsGauge.ToString() + " " + c.ToString());

            Debug.Log("after " + after.HitPointsGauge.BaseModifierSum + ") " + after.HitPointsGauge.ToString() + " " + after.ToString());



            Assert(after.ToString() == c.ToString());
        });
    }