public void AssignTarget(Ship ship)
    {
        target        = ship;
        target_weapon = target.GetComponent <ShipWeapon>();

        shipStats.AssigneTarget(ship);
    }
Exemple #2
0
 //By Jon G.; puts the current weapon in this slot back in player inventory, then sets a new weapon to the slot
 public void Replace(ShipWeapon newWeapon)
 {
     if (equippedWeapon != null)
     {
         PlayerStatus.Inventory.AddItem(equippedWeapon.CreateInstance());
     }
     equippedWeapon = (ShipWeapon)newWeapon.CreateInstance();
     newWeapon.Drop();
 }
Exemple #3
0
 private void CheckSingleFire(ShipWeapon weapon)
 {
     // Spara una singola volta per ogni volta che viene premuto
     // il tasto 'Space'
     if (Input.GetKeyDown(weapon.data.fireKeycode))
     {
         GenerateBullets(weapon);
     }
 }
Exemple #4
0
 public WeaponController(ShipWeapon reference)
 {
     _reference = reference;
     _controls  = new Dictionary <KeyCode, string>
     {
         { KeyCode.Alpha1, BulletBehavior.Normal },
         { KeyCode.Alpha2, BulletBehavior.Lazer },
         { KeyCode.Alpha3, BulletBehavior.Bomb }
     };
 }
Exemple #5
0
        /// <summary>
        /// ランダムに武器を設定する
        /// </summary>
        public void SetRandomWeapon(ShipStructure structure)
        {
            var weaponCon = structure.WeaponController;

            foreach (var w in weaponCon.Coms)
            {
                ShipWeapon weapon = weaponList.Get();
                w.SetEquipment(Instantiate(weapon));
                SetBullet(w.Equipment);
            }
        }
Exemple #6
0
    public void AddWeapon(ShipWeapon prefab)
    {
        ShipWeapon weapon = Instantiate(prefab, transform);

        weapon.gameObject.SetActive(true);
        weapon.transform.localPosition = Vector3.zero;
        weapon.transform.localRotation = Quaternion.identity;
        weapon.RefreshControllers();

        weapons.Add(weapon);
    }
Exemple #7
0
    private void CheckAutoFire(ShipWeapon weapon)
    {
        // Spara se è intercorso il
        // tempo per sparare il successivo proiettile
        if (weapon.timeToNextFire <= 0)
        {
            GenerateBullets(weapon);

            // Inizializzo il contatore per il fuoco multiplo
            weapon.timeToNextFire = weapon.data.fireInterval;
        }
    }
Exemple #8
0
 public bool isValidWeapon(ShipWeapon weapon, int slot)  // See if a weapon is valid. should be called before equipWeapon to avoid error
 {
     if (slot >= slotCount)
     {
         return(false);
     }
     if (!weaponSlots[slot].validWeapon(weapon))
     {
         return(false);
     }
     return(true);
 }
Exemple #9
0
        public override void Start()
        {
            base.Start();
            mWeapon    = RequireComponent <BaseWeapon>();
            mMessage   = RequireComponent <MmoMessageComponent>();
            mCharacter = RequireComponent <CharacterObject>();
            mTarget    = RequireComponent <PlayerTarget>();
            mMovable   = GetComponent <MovableObject>();
            m_Skills   = GetComponent <PlayerSkills>();
            m_Bonuses  = GetComponent <PlayerBonuses>();

            mChestLiveDuration = nebulaObject.world.Resource().ServerInputs.GetValue <float>("chest_life");
            //log.InfoFormat("chest life = {0}", mChestLiveDuration);
            mShotTimer = m_ShotCooldown;

            mDead = false;

            combatAIType = aiType as CombatAIType;
            if (combatAIType == null)
            {
                log.Error("CombatBasseAI must have CombatAIType, but not simple AIType");
            }
            mShipWeapon = GetComponent <ShipWeapon>();
            if (Rand.Int() % 2 == 0)
            {
                mMovNearTargetType = MovingNearTarget.Circle;
            }
            else
            {
                mMovNearTargetType = MovingNearTarget.LIne;
            }
            mStartPosition = nebulaObject.transform.position;

#if USE_SKILLS
            //--------------------------TESTING------------------------------------
            var ship = GetComponent <BaseShip>();
            if (ship)
            {
                string sSkill = skills[Rand.Int(skills.Count - 1)];
                ship.shipModel.Slot(ShipModelSlotType.CB).Module.SetSkill(SkillExecutor.SkilIDFromHexString(sSkill));
                mSkills = GetComponent <PlayerSkills>();
                mSkills.UpdateSkills(ship.shipModel);
            }
            //--------------------------------------------------------------------
#endif

            mBotObject = GetComponent <BotObject>();
            SetupSkills();
        }
Exemple #10
0
    public void SetVars(int n) //n is the number button this is, which determines invSlot, and therefore the Weapon this refers to and the text
    {
        invSlot = n;
        if (PlayerStatus.Ship.weaponSlots[invSlot].equippedWeapon != null)
        {
            shipWeapon        = PlayerStatus.Ship.weaponSlots[invSlot].equippedWeapon;
            armamentName.text = shipWeapon.GetName();
        }
        else
        {
            armamentName.text = "[EMPTY" + PlayerStatus.Ship.weaponSlots[invSlot].validTypesString() + " Slot]";
        }

        slot.text = "Slot " + (n + 1);
    }
Exemple #11
0
    public void SetVars(int n)
    {
        invSlot = n;
        if (PlayerStatus.Ship.weaponSlots[invSlot].equippedWeapon != null)
        {
            shipWeapon        = PlayerStatus.Ship.weaponSlots[invSlot].equippedWeapon;
            armamentName.text = shipWeapon.GetName();
        }
        else
        {
            armamentName.text = "[EMPTY]";
        }

        slot.text = "Slot " + (n + 1);
    }
Exemple #12
0
    public bool equipWeapon(ShipWeapon weapon, int slot)  // Attempt to equip weapon to this slot, returns true if equipped, false otherwise.
    {
        if (slot >= slotCount)
        {
            Debug.LogError("ERR: slot " + slot + " is not a valid slot on ship " + _name);
            return(false);
        }
        if (!weaponSlots[slot].validWeapon(weapon))
        {
            Debug.LogError("ERR: weapon type " + weapon._weaponType + " is not a valid type for slot " + slot + " on ship " + _name + ". valid types are: " + weaponSlots[slot].validTypesString());
            return(false);
        }

        weaponSlots[slot].equippedWeapon = weapon;
        return(true);
    }
Exemple #13
0
    private void CheckMultipleFire(ShipWeapon weapon)
    {
        // Spara se è intercorso il
        // tempo per sparare il successivo proiettile
        if (Input.GetKey(weapon.data.fireKeycode) && weapon.timeToNextFire <= 0)
        {
            GenerateBullets(weapon);

            // Inizializzo il contatore per il fuoco multiplo
            weapon.timeToNextFire = weapon.data.fireInterval;
        }

        // Se il tasto viene rilasciato, resetto il contatore del fuoco multiplo
        if (Input.GetKeyUp(weapon.data.fireKeycode))
        {
            weapon.timeToNextFire = 0;
        }
    }
Exemple #14
0
    private void GenerateBullets(ShipWeapon weapon)
    {
        // Crea una istanza del proiettile per ogni
        // spawn point (se è abilitato)
        foreach (GameObject spawn in weapon.spawnPoints)
        {
            if (!spawn.activeInHierarchy)
            {
                continue;
            }
            GameObject go = ObjectPooler.Instance.GetPooledObject(weapon.data.weaponPrefab);
            go.transform.position = spawn.transform.position;
            go.transform.rotation = spawn.transform.rotation;
//			GameObject go = GameObject.Instantiate (weapon.data.weaponPrefab, spawn.transform.position, spawn.transform.rotation);
//			go.name = weapon.data.name;
            go.SetActive(true);
        }
    }
Exemple #15
0
    // Funzione che controlla il fuoco delle armi
    private void CheckWeaponFire(ShipWeapon weapon)
    {
        switch (weapon.data.fireRate)
        {
        case FireRateType.Auto:
            CheckAutoFire(weapon);
            break;

        case FireRateType.Multiple:
            CheckMultipleFire(weapon);
            break;

        case FireRateType.Single:
            CheckSingleFire(weapon);
            break;

        default:
            break;
        }
    }
Exemple #16
0
        public override void Start()
        {
            if (!m_StartCalled)
            {
                m_StartCalled   = true;
                mShip           = RequireComponent <PlayerShip>();
                mTarget         = RequireComponent <PlayerTarget>();
                mCharacter      = RequireComponent <PlayerCharacterObject>();
                mAI             = RequireComponent <AIState>();
                mRace           = RequireComponent <RaceableObject>();
                mMessage        = RequireComponent <MmoMessageComponent>();
                mDamagable      = RequireComponent <ShipBasedDamagableObject>();
                mWeapon         = RequireComponent <ShipWeapon>();
                mSkills         = RequireComponent <PlayerSkills>();
                mBonuses        = RequireComponent <PlayerBonuses>();
                mPassiveBonuses = GetComponent <PassiveBonusesComponent>();

                mCharacter.SetCharacterId((string)nebulaObject.Tag((byte)PlayerTags.CharacterId));
                mCharacter.SetCharacterName((string)nebulaObject.Tag((byte)PlayerTags.Name));
                printPropertiesTimer = printPropertiesInterval;

                if (application.serverActors.ContainsKey(nebulaObject.Id))
                {
                    MmoActor old;
                    if (application.serverActors.TryRemove(nebulaObject.Id, out old))
                    {
                        log.Info("successfully remove actor before replacing with new [red]");
                    }
                }
                if (application.serverActors.TryAdd(nebulaObject.Id, this))
                {
                    log.Info("successfully added actor to server actors [red]");
                }

                //create chest on killing when player die
                mDamagable.SetCreateChestOnKilling(true);
                mDamagable.SetIgnoreDamageInterval(30);
                mDamagable.SetIgnoreDamageAtStart(true);
            }
        }
Exemple #17
0
    // Inizializzo le armi
    public void Init(WeaponsSystemData data)
    {
        // Inizializzo la lista
        _weapons = new List <ShipWeapon> ();

        // Cicla sulle armi recuperate dallo scriptable object
        // e successivamente recupera gli spawn points tramite i tag assegnati
        foreach (WeaponData wd in data.weapons)
        {
            ShipWeapon sw = new ShipWeapon();
            sw.data = wd;
            Transform[] allChildren = gameObject.GetComponentsInChildren <Transform>();
            foreach (Transform t in allChildren)
            {
                if (t.gameObject.tag == sw.data.tag)
                {
                    sw.spawnPoints.Add(t.gameObject);
                }
            }
            _weapons.Add(sw);
        }
    }
Exemple #18
0
 /// <summary>
 /// 武器に弾プールを設定する
 /// </summary>
 public void SetBullet(ShipWeapon weapon)
 {
     weapon.BulletPool = bulletPool.RegistObject(weapon.Bullet);
 }
Exemple #19
0
        /// <summary>
        /// Start is called before the first frame update
        /// </summary>
        private void Start()
        {
            ShipDefenses  defenses  = new ShipDefenses();
            ShipThrusters thrusters = new ShipThrusters();
            ShipWeaponry  weapons   = new ShipWeaponry();

            Vector2[] colliders = null;

            #region Setup

            defenses.ArmorStrength    = 50f;
            defenses.ShieldRecharge   = 1f;
            defenses.ShieldStrength   = 15f;
            defenses.ShieldDelay      = 5f;
            defenses.DamageResistance = 15f;

            thrusters.DampenerStrength     = 0.5f;              // Equivalent to rigidbody linear drag set before this temp code (shipDragRate was unused)
            thrusters.ForwardThrusterForce = 10f;               // Equivalent to shipAccRate set in the old player class ResetPlayer()
            thrusters.MaxDirectionalSpeed  = 10f;               // Equivalent to shipMaxSpd set in old player class
            thrusters.RecoilCompensation   = 0.9f;
            thrusters.ReverseThrusterForce = 3f;
            thrusters.RotationalSpeed      = 5f;                // Equivalent to shipRotSpd set in old player class

            ShipWeapon basicBlaster = new ShipWeapon();
            basicBlaster.Damage       = 5f;                     // Original hardcoded value in prototyped Projectile was 5
            basicBlaster.Name         = "Basic Blaster";
            basicBlaster.OutputPrefab = bulletPrefab;           // The prefabs and sounds will eventually be handled/stored outside Player
            basicBlaster.OutputSound  = bulletSound;
            basicBlaster.RateOfFire   = 0.35f;                  // Originally fireRate in old Player
            basicBlaster.Recoil       = 15f;                    // Originally -shipAcc * 5f when handling recoil in old Player
            basicBlaster.Speed        = 200f;                   // Originally projectileSpeed in old Player
            basicBlaster.Type         = WeaponType.projectile;
            ShipWeapon secondBlaster = new ShipWeapon();
            secondBlaster.Damage       = 1f;
            secondBlaster.Name         = "Secondary Blaster";
            secondBlaster.OutputPrefab = bulletPrefab;
            secondBlaster.OutputSound  = bulletSound2;
            secondBlaster.RateOfFire   = 0.2f;
            secondBlaster.Recoil       = 5f;
            secondBlaster.Speed        = 100f;
            secondBlaster.Type         = WeaponType.projectile;

            weapons.DamageModifier = 1;
            weapons.RateModifier   = 1;
            weapons.WeaponCount    = 3;
            weapons.Positions      = new List <Vector3>()
            {
                new Vector3(0.35f, 0, 0),
                new Vector3(0.25f, 0.21f, 0),
                new Vector3(0.25f, -0.21f, 0)
            };
            weapons.Rotations = new List <Vector3>
            {
                { new Vector3(0, 0, 0) },
                { new Vector3(0, 0, 10f) },
                { new Vector3(0, 0, -10f) }
            };
            weapons.SlotStatus = new List <WeaponSlotStatus>
            {
                { WeaponSlotStatus.enabled },
                { WeaponSlotStatus.enabled },
                { WeaponSlotStatus.enabled }
            };
            weapons.Weapons = new List <ShipWeapon>
            {
                { basicBlaster },
                { secondBlaster },
                { secondBlaster }
            };

            colliders = new Vector2[]                           // This is based off of what was in the PolygonCollider2D in old Player
            {
                new Vector2(0.25f, 0),
                new Vector2(-0.25f, 0.25f),
                new Vector2(-0.125f, 0),
                new Vector2(-0.25f, -0.25f)
            };

            #endregion

            Config = new ShipConfiguration(weapons, defenses, thrusters, 1, colliders, ShipSprite);
        }
Exemple #20
0
 // Use this for initialization
 void Awake()
 {
     weaponScript = this.transform.parent.GetComponent <ShipWeapon>();
 }
Exemple #21
0
 public bool validWeapon(ShipWeapon weapon)
 {
     return(acceptedTypes.Contains(weapon._weaponType));
 }
Exemple #22
0
        private void SetupSkills()
        {
            var ship = GetComponent <BaseShip>();

            if (ship)
            {
                var classMap = resource.npcSkills.GetClassSkillMap(mCharacter.myClass);
                if (classMap == null)
                {
                    return;
                }

                ShipWeapon shipWeapon = mWeapon as ShipWeapon;
                if (shipWeapon == null)
                {
                    return;
                }
                var colorMap = classMap.GetColorSkillList(NebulaEnumUtils.GetColorForDifficulty(shipWeapon.weaponDifficulty));

                if (colorMap == null)
                {
                    return;
                }

                int level          = mCharacter.level;
                int maxSkillsCount = 1;
                if (level < 2)
                {
                    maxSkillsCount = 1;
                }
                else if (level < 6)
                {
                    maxSkillsCount = 2;
                }
                else
                {
                    maxSkillsCount = 3;
                }

                if (maxSkillsCount >= colorMap.skills.Count)
                {
                    maxSkillsCount = colorMap.skills.Count;
                }
                List <int> filtered = colorMap.skills.Take(maxSkillsCount).ToList();
                m_CurrentSkills = filtered;

                for (int i = 0; i < filtered.Count; i++)
                {
                    int skill = colorMap.skills[i];
                    switch (i)
                    {
                    case 0: {
                        var module = ship.shipModel.Slot(ShipModelSlotType.CB).Module;
                        if (module != null)
                        {
                            module.SetSkill(skill);
                        }
                    }
                    break;

                    case 1: {
                        var module = ship.shipModel.Slot(ShipModelSlotType.CM).Module;
                        if (module != null)
                        {
                            module.SetSkill(skill);
                        }
                    }
                    break;

                    case 2: {
                        var module = ship.shipModel.Slot(ShipModelSlotType.DF).Module;
                        if (module != null)
                        {
                            module.SetSkill(skill);
                        }
                    }
                    break;
                    }
                }

                if (m_Skills)
                {
                    m_Skills.UpdateSkills(ship.shipModel);
                    //m_SlotsWithSkills = m_Skills.slotsWithSkill;
                }
            }

            //if (m_SlotsWithSkills == null) {
            //    m_SlotsWithSkills = new List<int>();
            //}
        }