Ejemplo n.º 1
0
    void Start()
    {
        SelfDelay = Delay;
        _h        = Owner.GetComponent <HealthModule>();
        if (Owner.GetComponent <Stats>())
        {
            _st       = Owner.GetComponent <Stats>();
            _as       = Owner.GetComponent <ActiveState>();
            _man      = Owner.GetComponent <Maneuvers>();
            IsShip    = true;
            IsStation = false;
        }
        if (Owner.GetComponent <Station>())
        {
            _sb       = Owner.GetComponent <Station>();
            _sbwm     = Owner.GetComponent <WeaponModule>();
            IsShip    = false;
            IsStation = true;
        }
        moove = true;

        AllTorpedose = new GameObject[poolSize];
        for (int i = 0; i < poolSize; i++)
        {
            AllTorpedose[i] = Instantiate(Shell) as GameObject;
            AllTorpedose[i].SetActive(false);
        }
    }
Ejemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        _PGS = gameObject.GetComponent <ArcReactor_Launcher>();

        _hm = Owner.GetComponent <HealthModule>();
        if (Owner.GetComponent <WeaponModule>())
        {
            _sbwm    = Owner.GetComponent <WeaponModule>();
            starship = false;
            starbase = true;
        }
        if (Owner.GetComponent <Stats>())
        {
            _st      = Owner.GetComponent <Stats>();
            _as      = Owner.GetComponent <ActiveState>();
            starship = true;
            starbase = false;
        }
        if (gameObject.GetComponent <AudioSource>())
        {
            _a              = gameObject.GetComponent <AudioSource>();
            _a.maxDistance  = 1000;
            _a.spatialBlend = 0.8f;
        }
    }
Ejemplo n.º 3
0
    public void AddModule(Module.ModuleType moduleType)
    {
        IModule newModule = null;

        switch (moduleType)
        {
        case Module.ModuleType.HullModule:
            newModule = new HullModule();
            break;

        case Module.ModuleType.WeaponModule:
            newModule = new WeaponModule();
            break;

        case Module.ModuleType.AerialTechModule:
            newModule = new AerialTechModule();
            break;

        case Module.ModuleType.None:
            Debug.LogWarning("ModuleType missing");
            //newModule = new Module();
            break;

        default:
            break;
        }

        newModule.IntegrateModule(playerController);
        integratedModules.Add(newModule);
    }
Ejemplo n.º 4
0
 // Use this for initialization
 void Start()
 {
     if (gameObject.GetComponent <Phaser>())
     {
         Phaser = true;
         if (gameObject.GetComponent <Phaser>().Owner.GetComponent <Stats>())
         {
             Ship     = true;
             ShipStat = gameObject.GetComponent <Phaser>().Owner.GetComponent <Stats>();
         }
         if (gameObject.GetComponent <Phaser>().Owner.GetComponent <Station>())
         {
             Station = true;
             _wm     = gameObject.GetComponent <Phaser>().Owner.GetComponent <WeaponModule>();
         }
     }
     if (gameObject.GetComponent <TopidoLounser>())
     {
         Torpedo = true;
         if (gameObject.GetComponent <TopidoLounser>().Owner.GetComponent <Stats>())
         {
             Ship     = true;
             ShipStat = gameObject.GetComponent <TopidoLounser>().Owner.GetComponent <Stats>();
         }
         if (gameObject.GetComponent <TopidoLounser>().Owner.GetComponent <Station>())
         {
             Station = true;
             _wm     = gameObject.GetComponent <TopidoLounser>().Owner.GetComponent <WeaponModule>();
         }
     }
 }
Ejemplo n.º 5
0
    public static void GetAssemblyDescData(Assembly assembly, out int cost, out int rootClass, out int techLevel, out int dps)
    {
        rootClass = PurchaseMenu.cur.GetModulePrefab(assembly.parts [0].type).GetComponent <Module> ().moduleClass;
        cost      = 0;
        techLevel = 0;
        dps       = 0;

        for (int i = 0; i < assembly.parts.Count; i++)
        {
            GameObject mod = PurchaseMenu.cur.GetModulePrefab(assembly.parts [i].type);
            cost += mod.GetComponent <Module> ().moduleCost;
            for (int j = 0; j < ResearchMenu.cur.research.Count; j++)
            {
                Research research = ResearchMenu.cur.research [j];

                if (research.func == "UnlockModule")
                {
                    if (mod == ResearchMenu.cur.unlockableModules [int.Parse(research.meta)] && techLevel < research.y)
                    {
                        techLevel = research.y;
                    }
                }
            }

            WeaponModule wep = mod.GetComponent <WeaponModule> ();
            if (wep)
            {
                dps += Mathf.RoundToInt(wep.weapon.GetDPS());
            }
        }
    }
Ejemplo n.º 6
0
    private void AssignWeapons()
    {
        weapon = new List <Weapon>();
        int index = GetComponent <Player>().index;

        if (index == 2)
        {
            int weaponCount = 1;
            foreach (Module w in GameManager.Instance.player1.Modules.moduleList)
            {
                if (w is WeaponModule)
                {
                    WeaponModule temp = (WeaponModule)w;
                    weapon.Add(new Weapon(temp.fireRate * fireRate, temp.damage, temp.projectile, weaponCount));
                    weaponCount++;
                }
            }
        }
        else if (index == 1)
        {
            int weaponCount = 1;
            foreach (Module w in GameManager.Instance.player2.Modules.moduleList)
            {
                if (w is WeaponModule)
                {
                    WeaponModule temp = (WeaponModule)w;
                    weapon.Add(new Weapon(temp.fireRate * fireRate, temp.damage, temp.projectile, weaponCount));
                    weaponCount++;
                }
            }
        }
    }
Ejemplo n.º 7
0
    public static Module sample(ModuleType type)
    {
        switch (type)
        {
        case ModuleType.Core:
            return(CoreModule.sample());

        case ModuleType.Energy:
            return(EnergyModule.sample());

        case ModuleType.Armor:
            return(ArmorModule.sample());

        case ModuleType.Computation:
            return(ComputationModule.sample());

        case ModuleType.Power:
            return(PowerModule.sample());

        case ModuleType.Weapon:
            return(WeaponModule.sample());

        case ModuleType.Repair:
            return(RepairModule.sample());

        case ModuleType.Battery:
            return(BatteryModule.sample());

        default:
            return(new Module(ModuleType.None, 0, 0, 0));
        }
    }
Ejemplo n.º 8
0
 public CraneSightPickup(float xval, float yval, WeaponModule <ISupportMediumSight> module) : base(xval, yval, "harp", module)
 {
     graphic         = new Sprite("tinyGun");
     center          = new Vec2(16f, 16f);
     collisionOffset = new Vec2(-6f, -4f);
     collisionSize   = new Vec2(12f, 8f);
 }
Ejemplo n.º 9
0
    void CheckShoot(WeaponModule wm)
    {
        Vector3 mousepos  = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        Vector3 bulletpos = this.GetComponent <BoxCollider2D>().bounds.center;

        mousepos.z = bulletpos.z = -1;
        Vector3 direction = (mousepos - bulletpos).normalized;

        Transform gunTransform = this.transform.GetChild(0);

        float gunAngle = gunTransform.eulerAngles.z;
        float angle    = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;

        gunTransform.RotateAround(bulletpos, Vector3.back, gunAngle - angle);
        if (Input.GetMouseButton(0) && Time.time - LastShootTime >= wm.shootingSpeed)
        {
            GameObject bul = Instantiate(bullet, bulletpos, Quaternion.identity) as GameObject;
            bul.name = "playerbullet";
            Bullet bulscript = bul.GetComponent <Bullet>();
            bulscript.shooter = gameObject;
            bulscript.Damage  = wm.singleDmg;
            Rigidbody2D bulrig = bul.GetComponent <Rigidbody2D>();
            bulrig.velocity = direction * bulletSpeed;
            LastShootTime   = Time.time;
        }
    }
Ejemplo n.º 10
0
 public void GetWeapon(int raw, int rol)
 {
     if (PlayerManager.instance.ModuleMap[raw, rol].type.Equals(ModuleType.Weapon))
     {
         weapon = (WeaponModule)PlayerManager.instance.ModuleMap[raw, rol];
     }
 }
Ejemplo n.º 11
0
 // Use this for initialization
 void Start()
 {
     if (!equipped)
     {
         slot = -1;
     }
     weapon = weaponPrefab.GetComponent <WeaponModule> ();
     info   = (GameObject)(Resources.Load("InventoryPrefabs/InfoPanelHover"));
 }
 //Generates a number of weapons using the options list. Very basic and doesn't enforce filling out all the slots in the weapon.
 public void Start()
 {
     for (int i = 0; i <= weaponsToGenerate; i++)
     {
         WeaponModule[] randomizedModuleSelection = new WeaponModule[optionsList.Length / 2];
         for (int x = 0; x < optionsList.Length / 2; x++)
         {
             randomizedModuleSelection[x] = optionsList[Random.Range(0, optionsList.Length)];
         }
         Weapon newWeapon = new Weapon(randomizedModuleSelection);
         weaponsList.Add(newWeapon);
     }
 }
Ejemplo n.º 13
0
 public Enemy(
     float maxHealth,
     MovementModule movementModule,
     WeaponModule weaponModule,
     Animator animatorNormal,
     Animator animatorExpl
     )
 {
     this.maxHealth      = maxHealth;
     health              = maxHealth;
     this.movementModule = movementModule;
     this.weaponModule   = weaponModule;
     this.animatorNormal = animatorNormal;
     this.animatorExpl   = animatorExpl;
     explDuration        = animatorExpl.GetLoopDuration();
     loopTimer           = LoopTimer.GetInstance();
 }
    private void ObjectNeutralisationEvent()
    {
        if (Ship)
        {
            if (maxCrew > 0)
            {
                if (curCrew <= 0)
                {
                    _st.AI            = false;
                    _st.FreandAI      = false;
                    _st.NeutralAgrass = false;
                    _st.Neutral       = true;

                    _st.targetTransform = null;
                    if (curCrew < 0)
                    {
                        curCrew = 0;
                    }
                }
            }
        }
        if (Station)
        {
            if (maxCrew > 0)
            {
                if (curCrew <= 0)
                {
                    _sb.AI            = false;
                    _sb.FreandAI      = false;
                    _sb.NeutralAgrass = false;
                    _sb.Neutral       = true;

                    if (_sb.WeaponModule)
                    {
                        WeaponModule _wm = gameObject.GetComponent <WeaponModule>();
                        _wm.target = null;
                    }
                    if (curCrew < 0)
                    {
                        curCrew = 0;
                    }
                }
            }
        }
    }
Ejemplo n.º 15
0
    private void SwapWeapon(int pos, Collider2D col)
    {
        WeaponModule wep = col.gameObject.GetComponent <WeaponModule> ();

        if (weaponSlots[pos].transform.childCount != 0)
        {
            WeaponModule unequip = weaponSlots [pos].transform.GetChild(0).GetComponent <WeaponModule> ();
            weaponModules.Remove(unequip);
            unequip.equipped           = false;
            unequip.transform.position = transform.position;
            weaponSlots [pos].transform.GetChild(0).parent = null;
            unequip.transform.localScale = unequip.originalSize;
            unequip.transform.rotation   = Quaternion.identity;
            unequip.sr.sortingOrder      = 0;

            //Ghetto weapon code
            unequip.Dropped(true);

            //Destroy (weaponSlots [pos].transform.GetChild (0).gameObject);
        }
        if (!wep.equipped)
        {
            wep.transform.localScale = wep.originalSize;
            wep.transform.parent     = weaponSlots [pos].transform;
            wep.transform.position   = new Vector2(
                weaponSlots [pos].transform.position.x,
                weaponSlots [pos].transform.position.y);
            wep.transform.localPosition = new Vector2(
                wep.transform.localPosition.x + wep.displacement.x,
                wep.transform.localPosition.y + wep.displacement.y);
            wep.transform.localScale = wep.transform.lossyScale;
            wep.sr.sortingOrder      = 2;
            weaponModules.Add(wep);
            wep.equipped = true;

            //Ghetto weapon code
            wep.Dropped(false);
        }
    }
Ejemplo n.º 16
0
    public void ReplaceWeapon(GameObject wep, int slot)
    {
        GameObject   wepobj  = Instantiate(wep) as GameObject;
        WeaponModule wepmod  = wepobj.GetComponent <WeaponModule> ();
        WeaponModule unequip = weaponSlots [slot - 1].transform.GetChild(0).GetComponent <WeaponModule> ();

        weaponModules.Remove(unequip);
        wepmod.OverrideStart();
        Destroy(weaponSlots [slot - 1].transform.GetChild(0).gameObject);
        wepmod.transform.localScale = wepmod.originalSize;
        wepmod.transform.parent     = weaponSlots [slot - 1].transform;
        wepmod.transform.position   = new Vector2(
            weaponSlots [slot - 1].transform.position.x,
            weaponSlots [slot - 1].transform.position.y);
        wepmod.transform.localPosition = new Vector2(
            wepmod.transform.localPosition.x + wepmod.displacement.x,
            wepmod.transform.localPosition.y + wepmod.displacement.y);
        wepmod.transform.localScale = wepmod.transform.lossyScale;
        wepmod.sr.sortingOrder      = 2;
        weaponModules.Add(wepmod);
        wepmod.equipped = true;
    }
Ejemplo n.º 17
0
 public void IntegrateStartModules()
 {
     while (integratedModules.Count < 5)
     {
         if (integratedModules.Count == 0)
         {
             IModule module = new AerialTechModule();
             module.IntegrateModule(playerController);
             integratedModules.Add(module);
         }
         if (integratedModules.Count > 3)
         {
             IModule module = new WeaponModule();
             module.IntegrateModule(playerController);
             integratedModules.Add(module);
         }
         else
         {
             IModule module = new HullModule();
             module.IntegrateModule(playerController);
             integratedModules.Add(module);
         }
     }
 }
Ejemplo n.º 18
0
 public Player()
 {
     pos = new SKPoint(
         Settings.Player.startPosX,
         Settings.Player.startPosY
         );
     speed               = 0;
     playerBitmapUp      = Helper.LoadBitmap("JetPack.media.player.up.png");
     playerBitmapDown    = Helper.LoadBitmap("JetPack.media.player.down.png");
     playerBitmapNeutral = Helper.LoadBitmap("JetPack.media.player.neutral.png");
     weaponModuleFactory = WeaponModuleFactory.GetInstance();
     loopTimer           = LoopTimer.GetInstance();
     weapon              = weaponModuleFactory.CreatePlayerWeapon(
         Settings.Player.Weapon.frequency,
         Settings.Player.Weapon.damage,
         Settings.Player.Weapon.projSpeed
         );
     weapon.SetFriendly();
     weapon.active = false;
     jetPackActive = false;
     animatorExpl  = new Animator(
         "JetPack.media.explosions.explosion1_",
         1,
         Settings.Player.explAnimStepDuration
         );
     explDuration    = Settings.Player.explAnimStepDuration * 1;
     animatorJetPack = new Animator(
         "JetPack.media.fire.fire_start_",
         "JetPack.media.fire.fire_hold_",
         "JetPack.media.fire.fire_stop_",
         8,
         23,
         19,
         Settings.Player.jetPackAnimStepDuration
         );
 }
Ejemplo n.º 19
0
 protected PickupModule(float xval, float yval, string pickSound, WeaponModule <T> module) : base(xval, yval, pickSound, 60)
 {
     _pickedup = module;
 }
Ejemplo n.º 20
0
    private void InitFittingsItemInfo()
    {
        WeaponModule wmodule = ModuleManager.Instance.FindModule <WeaponModule>();

        if (wmodule == null)
        {
            return;
        }

        PlayerDataModule module = ModuleManager.Instance.FindModule <PlayerDataModule>();

        if (module == null)
        {
            return;
        }
        FittingsTableItem fres = DataManager.FittingsTable[uiparam.itemid] as FittingsTableItem;

        if (fres == null)
        {
            GameDebug.LogError("资源ID为" + uiparam.itemid + "不存在表格fittings.txt中 ");
            return;
        }
        ConfigTableItem configitem = DataManager.ConfigTable[fres.grade] as ConfigTableItem;

        if (null == configitem)
        {
            return;
        }
        mFitName.text   = "[" + configitem.value + "]" + fres.name;
        mFitType.text   = "物品类型";
        mFitUseLv.text  = fres.itemtype;
        mFitDesc.text   = fres.itemdesc;
        mFitAbtain.text = fres.itemabtain;

        SetIcon(mFitPic, fres.bmp);
        SetIcon(mItemPic1, null);
        mItemLb.text = "";

        FittingsData fdata = module.GetFittingsData((uint)uiparam.packpos);

        if (fdata == null)
        {
            for (int i = 0; i < (int)FittingsType.MAX_PROPERTY; ++i)
            {
                mFitProNameList[i].text  = "";
                mFitproValueList[i].text = "";
            }
            mFitProNameList[0].text = "配件未洗练!";
            return;
        }

        for (int i = 0; i < (int)FittingsType.MAX_PROPERTY; ++i)
        {
            int  proid  = -1;
            int  value  = -1;
            bool forbid = false;
            if (!fdata.GetProValue((uint)i, ref proid, ref value, ref forbid))
            {
                continue;
            }

            string pname = RoleProperty.GetPropertyName(proid);
            if ("error".Equals(pname))
            {
                pname = "属性名称";
            }
            mFitProNameList[i].text = pname;

            int min = 0;
            int max = 1;
            if (!wmodule.GetFittMinMax(uiparam.itemid, proid, ref min, ref max))
            {
                mFitproValueList[i].text = "该条属性尚未洗炼!";
                continue;
            }

            mFitproValueList[i].text = value.ToString();

            /*int proindex = FittingsProperty.GetResId(proid);
             * string colorss = "000000";
             * Hashtable map = DataManager.FittcolorTable;
             * foreach (FittcolorTableItem fcres in map.Values)
             * {
             *  if (fcres.qualityid == fres.grade && value > System.Convert.ToInt32(fcres["max_" + proindex]))
             *      continue;
             *
             *  colorss = fcres.color;
             *  break;
             * }*/
        }
    }
Ejemplo n.º 21
0
    //枪械属性
    public static void BuildWeaponProperty(PlayerData mainData, PropertyOperation operation)
    {
        operation.Clear();
        //主武器属性
        WeaponObj obj = mainData.mPack.GetItemByID(mainData.main_weaponId, PackageType.Pack_Weapon) as WeaponObj;

        if (null != obj)
        {
            obj.BuildProperty(operation);
        }
        //强化属性
        StrenTableItem item = DataManager.StrenTable[mainData.mStrenLv] as StrenTableItem;

        if (null == item)
        {
            GameDebug.LogError("没有此强化等级 lv = " + mainData.mStrenLv);
            return;
        }
        operation.AddPro((int)PropertyTypeEnum.PropertyTypeDamage, item.value);
        int starlv = (int)(mainData.mStrenLv / (int)STARS_RANK.MAX_STARS_RANK_NUMBER);

        if (starlv > 0 && (mainData.mStrenLv % (int)STARS_RANK.MAX_STARS_RANK_NUMBER) == 0)
        {
            starlv -= 1;
        }
        if (0 != starlv)
        {
            for (int i = 1; i <= starlv; ++i)
            {
                StrProTableItem itempro = DataManager.StrProTable[i] as StrProTableItem;
                if (null == itempro)
                {
                    GameDebug.LogError("strenthpro.txt中不存在id = " + starlv);
                    return;
                }
                if (itempro.life != uint.MaxValue)
                {
                    operation.AddPro((int)PropertyTypeEnum.PropertyTypeMaxHP, itempro.life);
                }
                if (itempro.damage != uint.MaxValue)
                {
                    operation.AddPro((int)PropertyTypeEnum.PropertyTypeDamage, itempro.damage);
                }
                if (itempro.crits != uint.MaxValue)
                {
                    operation.AddPro((int)PropertyTypeEnum.PropertyTypeCrticalLV, itempro.crits);
                }
                if (itempro.defence != uint.MaxValue)
                {
                    operation.AddPro((int)PropertyTypeEnum.PropertyTypeDefance, itempro.defence);
                }
                if (itempro.energy != uint.MaxValue)
                {
                    operation.AddPro((int)PropertyTypeEnum.PropertyTypeMaxMana, itempro.energy);
                }
            }
        }
        //配件属性
        FittingsData[] mFittings = mainData.mFittings;
        WeaponModule   module    = ModuleManager.Instance.FindModule <WeaponModule>();

        if (null == module)
        {
            return;
        }
        for (int i = 0; i < (int)FittingsType.MAX_FITTGINS; ++i)
        {
            FittingsTableItem fittingsitem = DataManager.FittingsTable[mFittings[i].GetId()] as FittingsTableItem;
            if (null == fittingsitem)
            {
                break;
            }
            for (int j = 0; j < (int)FittingsType.MAX_PROPERTY; ++j)
            {
                int min = 0;
                int max = 1;
                if (!module.GetFittMinMax(mFittings[i].GetId(), mFittings[i].GetProIdByPos(j), ref min, ref max))
                {
                    continue;
                }

                operation.AddPro(mFittings[i].GetProIdByPos(j), mFittings[i].GetProValueByPos(j));
            }
        }
    }
 public void SetModules(WeaponModule weaponModule)
 {
     _weaponModule = weaponModule;
 }
Ejemplo n.º 23
0
 private void Start() {
     body = GetComponent<Rigidbody2D>();
     weaponModule = GetComponent<WeaponModule>();
     chasisModule = GetComponent<ChasisModule>();
 }