Inheritance: MonoBehaviour
    void Start()
    {
        weapon = GetComponent<WeaponBase>();

        // Store reference to nav-mesh-agent:
        navMeshAgent = GetComponent<NavMeshAgent>();

        // Get all colliders initially in range of Unit:
        SphereCollider sc = collider as SphereCollider;
        Collider[] collidersInRange = Physics.OverlapSphere(sc.center, sc.radius);

        // Add all our enemies to a list & a list of any initially in range:
        Transform childTran;
        int enemyCount = enemiesGroup.transform.childCount;
        for ( int i = 0; i < enemyCount; i ++ )
        {
            childTran = enemiesGroup.transform.GetChild( i );
            enemiesTransformList.Add( childTran );

            if ( Array.IndexOf( collidersInRange, childTran.collider ) != -1 )
            {
                inRangeList.Add( childTran );
            }
        }
    }
Beispiel #2
0
 public GameController(IGameFactory game)
 {
     _random = new Random(10);
     _fighter = game.CreateFighter();
     _victim = game.CreateVictim();
     _weapon = game.CreateWeapon();
 }
Beispiel #3
0
 public HitResult(PlayerBase player, WeaponBase weapon)
 {
     var newEnergy = player.Energy - weapon.Effect;
     var deathValue = 0;
     NewEnergyOfPlayer = newEnergy <= deathValue ? deathValue : newEnergy;
     NameOfWeapon = weapon.Name;
 }
 public void SetUpVariables(PlayerBase pb, BulletManager bm, WeaponBase wb)
 {
     this.wb = wb;
     playerBase = pb;
     bulletManager = bm;
     animator = GetComponent<Animator>();
 }
 public void SetUpVariables(PlayerBase pb, BulletManager bm, WeaponBase wb)
 {
     transform.localScale = new Vector3(1.1f, 1.1f, 0);
     this.wb = wb;
     playerBase = pb;
     bulletManager = bm;
     animator = GetComponent<Animator>();
 }
    // Use this for initialization
    void Start()
    {
        weapons = this.GetComponents<WeaponBase>();
        currentWeapon = weapons[weaponIndex];
        var clickStream = UpdateAsObservable ()
            .Where (_ => currentWeapon.FireTrigger());

        var rightclickStream = UpdateAsObservable ()
            .Where (_ => Input.GetMouseButtonDown(1) || Input.GetKeyDown(KeyCode.R));

        var weaponChangeStreamQ = UpdateAsObservable ()
            .Where (_ => Input.GetKeyDown (KeyCode.Q));
        var weaponChangeStreamE = UpdateAsObservable ()
            .Where (_ => Input.GetKeyDown (KeyCode.E));

        clickStream.TimeInterval().Where(l=>{
            interval += l.Interval.TotalMilliseconds;
            return interval  > currentWeapon.FireRatePerMilliSec;} ).Subscribe (_ =>
        {
            interval = 0;
            if (currentWeapon.CanFire)
            {
                currentWeapon.Fire(camera);
            }
            else if (!currentWeapon.IsReloading)
            {
                currentWeapon.Reload();
            }
        }).AddTo(this);

        rightclickStream.Subscribe (_ =>
                                    {
            if (!currentWeapon.IsReloading)
            {
                currentWeapon.Reload();
            }
        }).AddTo(this);

        weaponChangeStreamQ.Subscribe (_ =>{
            weaponIndex--;
            if (weaponIndex < 0)
                weaponIndex = weapons.Length -1;
            currentWeapon = weapons[weaponIndex];
        }).AddTo(this);
        weaponChangeStreamE.Subscribe (_ =>{
            weaponIndex++;
            if (weaponIndex >= weapons.Length)
                weaponIndex = 0;
            currentWeapon = weapons[weaponIndex];
        }).AddTo(this);

        guardTarget.ObserveEveryValueChanged (x => x.currentHelth)
                .Subscribe (helth => {
                Debug.Log("helth: "+helth);
                    if (helth <= 0)
                        Application.LoadLevel(Application.loadedLevelName);
        }).AddTo(this);
    }
Beispiel #7
0
 protected void Awake()
 {
     motor = GetComponent<CharacterMotor>();
     currentGun = GetComponentInChildren<WeaponBase>();
     startVelocity = motor.movement.maxForwardSpeed;
     if(!isEnemy){
         currentGun.AxiX = GetComponent<MouseLook>();
         currentGun.axiY = Camera.mainCamera.GetComponent<MouseLook>();
     }
 }
Beispiel #8
0
    void ChangeWep(WeaponBase toWep)
    {
        SoundCenter.instance.PlayClipOn(
            SoundCenter.instance.playerWepSwitch,transform.position);

        foreach(WeaponBase eachWep in allWep) {
            eachWep.enabled = (eachWep == toWep);
        }

        dartGunModel.SetActive(toWep == dartGun);
        waterGunModel.SetActive(toWep == soakerGun);
        canThrowerModel.SetActive(toWep == sodaGrenadeThrower);
    }
Beispiel #9
0
    public virtual void OnBulletCreated( WeaponBase _weapon, BulletBase _bullet )
    {
        SmartBullet smartBullet = _bullet as SmartBullet;
        if ( smartBullet != null )
        {
            smartBullet.health.Owner = this.health.Owner;
        }

        SeekingBullet seekingScript = _bullet as SeekingBullet;
        if ( seekingScript != null
        && ( !_weapon.weaponDesc.requiresWeaponLock || _weapon.IsLockedOntoTarget() ) )
        {
            seekingScript.target = this.currentTarget;
        }
    }
Beispiel #10
0
    // ------------------------------------------------------------------ 
    // Desc: 
    // ------------------------------------------------------------------ 

    void Awake () {
        if( weaponBase == null ) {
            weaponBase = this;

            // we need instantiate weapon from prefab
            for ( int i = 0; i < this.weaponList.Length; ++i ) {
                WeaponPrefabInfo prefabInfo = this.weaponList[i];
                GameObject weaponGO 
                    = GameObject.Instantiate(prefabInfo.prefab, 
                                             Vector3.zero, 
                                             Quaternion.identity ) as GameObject; 
                weaponGO.SetActiveRecursively(false);
                DebugHelper.Assert( prefabInfo.id != WeaponID.unknown,
                                    "Are you insane? the weaponID is unknown!" );
                this.weaponLookupTable[prefabInfo.id] = weaponGO;
            }
            this.weaponList = null; // after we init Dictionary, we don't need the array.
        }
    }
    public void fire(FireProps fp, PlayerBase pb, WeaponBase wb)
    {
        this.pb = pb;
        this.fp = fp;
        this.wb = wb;
        fired = true;
        colider.enabled = true;
        nullAllAnimBools();
        setBoolAnimator("flameStart", true);

        if (!pb.isAi)
        {
            chosenAudioSourceIndex = SoundManager.instance.PlaySingle(flamethrowerSound, true);

        }
        else if(pb.isAi && !soundLoop)
        {
            chosenAudioSourceIndex = SoundManager.instance.PlaySingle(flamethrowerSound, true);
            soundLoop = true;
        }
    }
Beispiel #12
0
    //destroys the old instance of the weapon script
    //and adds a new weapon script to the unit
    public virtual void equipWeapon(ItemWeapon newWeapon)
    {
        GameObject.Destroy(weapon);

        if (newWeapon != null)
        {
            weapon = (WeaponBase) gameObject.AddComponent("" + newWeapon.weaponType);//weaponType enum name will match weapon script name
        }
        else
        {
            weapon = null;
        }
    }
Beispiel #13
0
    /// <summary>
    /// Set a arma 
    /// </summary>
    void ChangeWeapon(WeaponBase setupWeapon_)
    {
        if (WeaponBone != null && setupWeapon_ != null)
        {
            if (CurrentWeapon != null)
            {				
                	CurrentWeapon.transform.parent = null;
                	CurrentWeapon.gameObject.SetActive(false);
                	CurrentWeapon.transform.parent = this.transform;
            }
            else
            {
                CurrentWeapon = setupWeapon_;
				CurrentWeapon.transform.SetParent(WeaponBone.transform, false);
            	CurrentWeapon.gameObject.SetActive(true);
            	CurrentWeapon.WeaponOwner = this;
				CurrentWeapon.RenderWeapon = RenderWeapon;
            }
        }
    }
Beispiel #14
0
 protected virtual void Start()
 {
     weapon = gameObject.GetComponent<WeaponBase>();
 }
Beispiel #15
0
    void Update()
    {
        updateRenderVisibility();

        if (!isLocalPlayer)
        {
            return;
        }

        //visibility
        if (!IsInvisible)
        {
            _timer += Time.deltaTime;
        }
        if (_timer > 2)
        {
            CmdSetInvisible(true);
            _timer = 0;
        }

        var x = Input.GetAxis("Horizontal") * Time.deltaTime * PlayerSpeed;
        var z = Input.GetAxis("Vertical") * Time.deltaTime * PlayerSpeed;

        if (WeaponToEquip != null)
        {
            EquipWeapon(WeaponToEquip);
            WeaponToEquip = null;
        }

        Plane playerPlane = new Plane(Vector3.up, transform.position);

        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        float hitdist = 0.0f;

        if (playerPlane.Raycast(ray, out hitdist))
        {
            Vector3 targetPoint = ray.GetPoint(hitdist);

            Quaternion targetRotation = Quaternion.LookRotation(targetPoint - transform.position);

            transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, 30 * Time.deltaTime);
        }

        transform.Translate(x, 0, z, Space.World);

        if (Input.GetMouseButtonDown(0))
        {
            if (_equipedWeapon != null)
            {
                _equipedWeapon.ButtonDown();
            }
        }

        if (Input.GetMouseButtonUp(0))
        {
            if (_equipedWeapon != null)
            {
                _equipedWeapon.ButtonUp();
            }
        }
        if (_equipedWeapon != null)
        {
            _equipedWeapon.RunUpdate(Time.deltaTime);
        }
    }
Beispiel #16
0
    public void OnPickup(MeteorUnit unit)
    {
        //场景上的模型物件捡取
        if (unit.Dead)
        {
            return;
        }
        if (ItemInfo != null && root != null)
        {
            if (ItemInfo.IsWeapon())
            {
                //满武器,不能捡
                if (unit.Attr.Weapon != 0 && unit.Attr.Weapon2 != 0)
                {
                    return;
                }
                //相同武器,不能捡
                ItemBase   ib0 = GameData.FindItemByIdx(unit.Attr.Weapon);
                WeaponBase wb0 = WeaponMng.Instance.GetItem(ib0.UnitId);
                if (wb0 != null && wb0.WeaponR == ItemInfo.model)
                {
                    return;
                }

                if (unit.Attr.Weapon2 != 0)
                {
                    ItemBase   ib1 = GameData.FindItemByIdx(unit.Attr.Weapon2);
                    WeaponBase wb1 = WeaponMng.Instance.GetItem(ib1.UnitId);
                    if (wb1 != null && wb1.WeaponR == ItemInfo.model)
                    {
                        return;
                    }
                }

                //同类武器不能捡
                int      weaponPickup = GameData.GetWeaponCode(ItemInfo.model);
                ItemBase wb           = GameData.FindItemByIdx(weaponPickup);
                if (wb == null)
                {
                    return;
                }

                ItemBase wbl = GameData.FindItemByIdx(unit.Attr.Weapon);
                if (wbl == null)
                {
                    return;
                }

                ItemBase wbr = GameData.FindItemByIdx(unit.Attr.Weapon2);
                if (wb.SubType == wbl.SubType)
                {
                    return;
                }

                if (wbr != null && wb.SubType == wbr.SubType)
                {
                    return;
                }
                //可以捡取
                unit.Attr.Weapon2 = weaponPickup;
                SFXLoader.Instance.PlayEffect(672, unit.gameObject, true);
                refresh_tick = ItemInfo.first[1].flag[1];
                if (asDrop)
                {
                    GameObject.Destroy(gameObject);
                }
                else
                {
                    if (refresh_tick > 0)
                    {
                        Refresh = true;
                    }
                    GameObject.Destroy(root.gameObject);
                    root = null;
                }
            }
            else if (ItemInfo.IsItem())
            {
                //表明此为Buff,会叠加某个属性,且挂上一个持续的特效。
                unit.GetItem(ItemInfo);
                refresh_tick = ItemInfo.first[1].flag[1];
                if (refresh_tick > 0)
                {
                    Refresh = true;
                }
                GameObject.Destroy(root.gameObject);
                root = null;
            }
            else if (ItemInfo.IsFlag())
            {
                GameObject.Destroy(root.gameObject);
                root = null;
                if (ItemInfo.first[1].flag[1] != 0)
                {
                    SFXLoader.Instance.PlayEffect(ItemInfo.first[1].flag[1], unit.gameObject, false);
                }
                U3D.InsertSystemMsg(unit.name + " 夺得镖物");
                unit.SetFlag(ItemInfo, ItemInfo.first[2].flag[1]);
            }
        }
        else if (ItemInfoEx != null)
        {
            if (ItemInfoEx.MainType == 1)
            {
                string     weaponModel = "";
                WeaponBase wp          = WeaponMng.Instance.GetItem(ItemInfoEx.UnitId);
                if (wp != null)
                {
                    weaponModel = wp.WeaponR;
                }
                //满武器,不能捡
                if (unit.Attr.Weapon != 0 && unit.Attr.Weapon2 != 0)
                {
                    return;
                }
                //相同武器,不能捡
                ItemBase   ib0 = GameData.FindItemByIdx(unit.Attr.Weapon);
                WeaponBase wb0 = WeaponMng.Instance.GetItem(ib0.UnitId);
                if (wb0 != null && wb0.WeaponR == weaponModel)
                {
                    return;
                }

                if (unit.Attr.Weapon2 != 0)
                {
                    ItemBase   ib1 = GameData.FindItemByIdx(unit.Attr.Weapon2);
                    WeaponBase wb1 = WeaponMng.Instance.GetItem(ib1.UnitId);
                    if (wb1 != null && wb1.WeaponR == weaponModel)
                    {
                        return;
                    }
                }

                //同类武器不能捡
                int      weaponPickup = GameData.GetWeaponCode(weaponModel);
                ItemBase wb           = GameData.FindItemByIdx(weaponPickup);
                if (wb == null)
                {
                    return;
                }

                ItemBase wbl = GameData.FindItemByIdx(unit.Attr.Weapon);
                if (wbl == null)
                {
                    return;
                }

                ItemBase wbr = GameData.FindItemByIdx(unit.Attr.Weapon2);
                if (wb.SubType == wbl.SubType)
                {
                    return;
                }

                if (wbr != null && wb.SubType == wbr.SubType)
                {
                    return;
                }
                //可以捡取
                unit.Attr.Weapon2 = weaponPickup;
                SFXLoader.Instance.PlayEffect(672, unit.gameObject, true);

                if (asDrop)
                {
                    GameObject.Destroy(gameObject);
                }
            }
        }
    }
Beispiel #17
0
 protected override void Creation()
 {
     WeaponKind = WeaponBase.RandomWeaponKind();
 }
Beispiel #18
0
    public void OnOrcPickup(Vector3 pos)
    {
        SaveGame.RoundScore++;
        GameEvents.CounterEvent(GameCounter.Score_Any_Sum, 1);
        GameEvents.CounterEvent(GameCounter.Max_Score_Any, SaveGame.RoundScore);

        if (GameMode == GameModeEnum.Nursery)
        {
            GameEvents.CounterEvent(GameCounter.Score_Nursery_Sum, 1);
            GameEvents.CounterEvent(GameCounter.Max_Score_Nursery, SaveGame.RoundScore);
        }
        else if (GameMode == GameModeEnum.Earth)
        {
            GameEvents.CounterEvent(GameCounter.Score_Earth_Sum, 1);
            GameEvents.CounterEvent(GameCounter.Max_Score_Earth, SaveGame.RoundScore);
        }
        else if (GameMode == GameModeEnum.Wind)
        {
            GameEvents.CounterEvent(GameCounter.Score_Wind_Sum, 1);
            GameEvents.CounterEvent(GameCounter.Max_Score_Wind, SaveGame.RoundScore);
        }
        else if (GameMode == GameModeEnum.Fire)
        {
            GameEvents.CounterEvent(GameCounter.Score_Fire_Sum, 1);
            GameEvents.CounterEvent(GameCounter.Max_Score_Fire, SaveGame.RoundScore);
        }
        else if (GameMode == GameModeEnum.Storm)
        {
            GameEvents.CounterEvent(GameCounter.Score_Storm_Sum, 1);
            GameEvents.CounterEvent(GameCounter.Max_Score_Storm, SaveGame.RoundScore);
        }
        else if (GameMode == GameModeEnum.Harmony)
        {
            GameEvents.CounterEvent(GameCounter.score_Harmony_Sum, 1);
            GameEvents.CounterEvent(GameCounter.Max_score_Harmony, SaveGame.RoundScore);
        }

        AudioManager.Instance.PlayClipWithRandomPitch(AudioManager.Instance.MiscAudioSource, AudioManager.Instance.AudioData.OrcPickup);

        Vector2 uiPos         = UiPositionFromWorld(PlayerTrans.position + Vector3.up * 0.5f);
        var     rectTransform = TextFloatingWeapon.GetComponent <RectTransform>();

        rectTransform.anchoredPosition = uiPos;

        TextScore.text = SaveGame.RoundScore.ToString();

        if (CurrentDeedData.Deed != DeedEnum.Sandbox)
        {
            Unlocks.SetRandomWeapon();
            TextFloatingWeapon.SetText(WeaponBase.WeaponDisplayName(PlayerScript.Weapon.Type), 2.0f);
        }

        if (CurrentDeedData.ShowOrcs)
        {
            Vector3 bestPos      = Vector3.zero;
            float   bestDistance = 0.0f;
            for (int i = 0; i < 5; ++i)
            {
                Vector3 newPos   = PositionUtility.GetPointInsideArena(1.0f, 0.9f);
                float   distance = Vector3.Distance(newPos, pos);
                if (distance > bestDistance)
                {
                    bestDistance = distance;
                    bestPos      = newPos;
                }

                // TODO PE: Does not seem to work? I've seen it behind the score.
                // Let's try not placing the orc around the UI
                bool nearUi = newPos.y > 4.5f && (newPos.x > -3.5f && newPos.x < 3.5f);
                if (nearUi)
                {
                    continue;
                }

                if (distance > 5.0f)
                {
                    break;
                }
            }

            Orc.SetPosition(bestPos);
            MakeFlash(bestPos, 2.0f);
        }
        else
        {
            // Hide the orc
            Orc.SetPosition(Vector3.left * 10000);
        }
    }
Beispiel #19
0
    private void Update()
    {
        // Weapon Sprite and Name Update
        if (_weapon != PlayerManager.PlayerHandController.CurrentWeapon)
        {
            _weapon = PlayerManager.PlayerHandController.CurrentWeapon;
            WeaponUI.WeaponImage.sprite = _weapon.WeaponRenderer.sprite;            // Weapon Info
            WeaponUI.WeaponImage.SetNativeSize();
            WeaponUI.WeaponText.text  = _weapon.Weapon.Name;
            WeaponUI.AmmoImage.sprite = _weapon.Weapon.Bullet.Renderer.sprite;  // Ammo Info
            WeaponUI.AmmoImage.SetNativeSize();
        }

        // Ammo Count Update
        if (_ammo != PlayerManager.PlayerHandController.CurrentWeapon.CurrentAmmo)
        {
            _ammo = PlayerManager.PlayerHandController.CurrentWeapon.CurrentAmmo;
            WeaponUI.AmmoText.text = "" + _ammo;
            if (_ammo == 0)
            {
                WeaponUI.SetColor(absentColor);     // Setting color of ammo bar
                if (_reloadTimer <= 0)              // Starts reloading
                {
                    _reloadTimer = _weapon.Weapon.ReloadTime;
                }
            }
            else
            {
                WeaponUI.SetColor(existColor);
            }
        }

        // Setting Reload Slider
        if (_reloadTimer > 0)
        {
            _reloadTimer -= Time.deltaTime;
            WeaponUI.SetReloadSlider(_reloadTimer / _weapon.Weapon.ReloadTime);
            if (_reloadTimer <= 0)
            {
                WeaponUI.SetReloadSlider(1);
            }
        }


        // Health Count Update
        if (_health != PlayerManager.HealthController.Health)
        {
            _health = PlayerManager.HealthController.Health;
            MiscUI.HealthText.text = "" + _health;
            MiscUI.SetHealthColor((float)_health / 100);
        }

        // Medkit Count Update
        if (_medkit != PlayerManager.Inventory[(int)GameConfigData.CollectibleType.Medkit].Count)
        {
            _medkit = PlayerManager.Inventory[(int)GameConfigData.CollectibleType.Medkit].Count;
            MiscUI.MedkitText.text = "" + _medkit;
            MiscUI.SetMedkitColor(_medkit == 0 ? absentColor : existColor);    // Setting color of medkit bar
        }

        // Shield Count Update
        if (_shield != PlayerManager.Inventory[(int)GameConfigData.CollectibleType.Shield].Count)
        {
            _shield = PlayerManager.Inventory[(int)GameConfigData.CollectibleType.Shield].Count;
            MiscUI.ShieldText.text = "" + _shield;
            MiscUI.SetShieldColor(_shield == 0 ? absentColor : existColor);    // Setting color of shield bar
        }

        // Key Owning Update
        if (_hasKey != PlayerManager.HasKey)
        {
            _hasKey = PlayerManager.HasKey;
            MiscUI.KeyUI.SetActive(true);
        }

        // Level Value Update
        if (_level != GameManager.DungeonLevel)
        {
            _level = GameManager.DungeonLevel;
            LevelUI.LevelText.text = "Level " + (_level + 1);
        }
    }
 public void UpdateActiveWeaponDisplay(WeaponBase weapon)
 {
     currentWeaponTextElement.text = $"Current Weapon:\n{weapon}";
 }
Beispiel #21
0
 void DisableWeapon(WeaponBase weapon)
 {
     weapon.IsEnabled = false;
 }
Beispiel #22
0
    public void LoadWeapon()
    {
        InventoryItem item = Weapon;

        if (item.Info().MainType == (int)EquipType.Weapon)
        {
            float      scale          = 1.0f;
            WeaponBase weaponProperty = WeaponMng.Instance.GetItem(item.Info().UnitId);
            string     weaponR        = "";
            weaponR = weaponProperty.WeaponR;

            if (!string.IsNullOrEmpty(weaponR))
            {
                GameObject weaponPrefab = Resources.Load <GameObject>(weaponR);
                if (weaponPrefab == null)
                {
                    GMCFile fGmcL = GMCLoader.Instance.Load(weaponR);
                    DesFile fDesL = DesLoader.Instance.Load(weaponR);

                    if (fGmcL != null && fDesL != null)
                    {
                        GenerateWeaponModel(weaponR, fGmcL, fDesL, scale, weaponProperty.TextureL);
                    }
                    else if (fGmcL == null && fDesL != null)
                    {
                        GMBFile fGmbL = GMBLoader.Instance.Load(weaponR);
                        GenerateWeaponModel(weaponR, fGmbL, fDesL, scale, weaponProperty.TextureL);
                    }
                }
                else
                {
                    if (R != null)
                    {
                        DestroyImmediate(R);
                    }
                    GameObject objWeapon = GameObject.Instantiate(weaponPrefab);
                    objWeapon.layer = LayerMask.NameToLayer("Flight");
                    R = objWeapon.transform;
                    //L = new GameObject().transform;
                    R.SetParent(WeaponRoot);
                    R.localPosition = Vector3.zero;
                    //这种导入来的模型,需要Y轴旋转180,与原系统的物件坐标系存在一些问题
                    R.localRotation = new Quaternion(0, 1, 0, 0);
                    R.name          = weaponR;
                    R.localScale    = Vector3.one;

                    //每个武器只能有一个碰撞盒
                    BoxCollider box = R.GetComponentInChildren <BoxCollider>();
                    if (box != null)
                    {
                        box.enabled = false;
                        //box.gameObject.tag = "Flight";
                        box.gameObject.layer = LayerMask.NameToLayer("Flight");
                        //weaponDamage.Add(box);
                    }
                    else
                    {
                        Debug.LogError("新增武器上找不到碰撞盒[除了暗器火枪飞轮外都应该有碰撞盒]");
                    }
                }
            }
        }
    }
Beispiel #23
0
 public void OnCurrentWeaponChanged(WeaponBase Weapon)
 {
     this.hudWeaponSelector.OnCurrentWeaponChanged(Weapon);
     this.hudCrosshair.OnCurrentWeaponChanged(Weapon.WeaponID);
 }
Beispiel #24
0
        internal void CleanUp()
        {
            AiCloseTick = Session.Tick;

            MyGrid.Components.Remove <AiComponent>();

            for (int i = 0; i < MIds.Length; i++)
            {
                MIds[i] = 0;
            }

            if (Session.IsClient)
            {
                Session.SendUpdateRequest(MyGrid.EntityId, PacketType.ClientAiRemove);
            }

            Data.Repo.ControllingPlayers.Clear();
            Data.Repo.ActiveTerminal = 0;

            CleanSortedTargets();
            Construct.Clean();
            Obstructions.Clear();
            ObstructionsTmp.Clear();
            TargetAis.Clear();
            TargetAisTmp.Clear();
            EntitiesInRange.Clear();
            Batteries.Clear();
            Targets.Clear();
            Weapons.Clear();
            WeaponsIdx.Clear();
            WeaponBase.Clear();
            LiveProjectile.Clear();
            DeadProjectiles.Clear();
            NearByShieldsTmp.Clear();
            NearByFriendlyShields.Clear();
            StaticsInRange.Clear();
            StaticsInRangeTmp.Clear();
            TestShields.Clear();
            NewEntities.Clear();
            SubGridsRegistered.Clear();
            SourceCount           = 0;
            BlockCount            = 0;
            AiOwner               = 0;
            ProjectileTicker      = 0;
            NearByEntities        = 0;
            NearByEntitiesTmp     = 0;
            MyProjectiles         = 0;
            AccelChecked          = false;
            PointDefense          = false;
            FadeOut               = false;
            SuppressMouseShoot    = false;
            OverPowered           = false;
            UpdatePowerSources    = false;
            AvailablePowerChanged = false;
            PowerIncrease         = false;
            RequestedPowerChanged = false;
            RequestIncrease       = false;
            DbReady               = false;
            GridInit              = false;
            TouchingWater         = false;
            Data.Clean();

            MyShield         = null;
            MyPlanetTmp      = null;
            MyPlanet         = null;
            TerminalSystem   = null;
            LastTerminal     = null;
            PowerDistributor = null;
            PowerBlock       = null;
            MyGrid           = null;
            PowerDistributor = null;
            Session          = null;
            Closed           = true;
            CanShoot         = true;
            Version++;
        }
Beispiel #25
0
 public AllMonsters(AllCharactersModel character, WeaponBase weapon, bool isHardHeaded) : base(character, weapon)
 {
     IsHardHeaded = isHardHeaded;
 }
Beispiel #26
0
 public AggressiveGuard(WeaponBase model) : base(new AllCharactersModel("Agressive Advespa Guard", "The loud humming sound above is what gets your attention first. Hovering above you with two sets of translucent wings is a 6ft bug creature, bobbing angrily once it notices your presences and starts inspecting you. \n\n It resembled a hornet in color and shape; but where there would normally be two large, black compound-eyes and mandibles, is a deformed woman's face staring back at you. What's left of her lips are pulled back in a permanent sneer, stretched painfully wide due to the miniature mandibles growing from the gums in her mouth. One of her eyes still appears normal, although blown out and wild looking; the other seems to be in the middle of deforming into a more bug like orb. A pair of antennae have forced their way through her forehead just along her hairline, the skin long since peeled back and left to hang and fall off.", 30, 30, 6, 5), new StingerArrows(), true)
 {
 }
Beispiel #27
0
        public void SetUp(bool canRecall)
        {
            gameObject.AddComponent <WeaponBase>().type = WeaponType.ArmorBreaker;

            WeaponBase wb = GetComponent <WeaponBase>();

            //wb.type = WeaponType.ArmorBreaker;

            blade  = transform.GetChild(0).gameObject;
            handle = transform.GetChild(1).gameObject;

            if (handle == null || blade == null)
            {
                Debug.LogError("BLADE OR HANDLE IS MISSING!");
                return;
            }


            WeaponHandle wh;

            if (canRecall)
            {
                handle.AddComponent <MjolnirHandle>();
                wh = handle.GetComponent <MjolnirHandle>();
            }
            else
            {
                handle.AddComponent <WeaponHandle>();
                wh = handle.GetComponent <WeaponHandle>();
            }

            wb.grabbable    = wh;
            wb.canParry     = true;
            wb.canBeParried = true;
            wb.addForceToRigidbodyFactor = 0.6f;

            wh.grabRigidbody       = wh.GetComponent <Rigidbody>();
            wh.hideHandModelOnGrab = true;
            wh.isCurrentlyGrabbale = true;
            wh.setPositionOnGrab   = true;
            wh.setRotationOnGrab   = true;

            DamagerRigidbody drb = blade.AddComponent <DamagerRigidbody>();

            drb.scaleDamage   = 1.2f;
            drb.canAlsoCut    = false;
            drb.bonusVelocity = 0.7f;
            drb.isDamaging    = true;
            drb.impaleDepth   = 1f;
            drb.damageType    = DamageType.Blunt;

            handle.AddComponent <FootStepSound>().soundEffectName    = "WeaponDrop";
            handle.GetComponent <FootStepSound>().minVolumeToTrigger = 0.05f;

            /*
             * try
             * {
             *  if (transform.GetChild(2) != null)
             *  {
             *      drb.heartStabPoint = transform.GetChild(2);
             *
             *      drb.impaledBreakForce = weapon.impaleBreakForce;
             *      drb.impaledZDamper = weapon.impaleZDamper;
             *      drb.impaledConnectedBodyMassScale = weapon.connectedBMass;
             *  }
             * }
             * catch
             * {
             *  return;
             * }
             */

            return;
        }
Beispiel #28
0
 protected virtual void SetWeapon(WeaponBase weapon)
 {
     m_weapon = weapon;
 }
Beispiel #29
0
    public static WeaponBase GetItem(long objNo, bool isRandomValue)
    {
        TableWeaponData data = Array.Find(Table, i => i.ObjNo == objNo);
        WeaponBase      item = new WeaponBase();

        item.Initialize();
        item.ObjNo = data.ObjNo;
        if (GameStateInformation.IsEnglish == false)
        {
            item.DisplayName = data.DisplayName;
            item.Description = data.Description;
        }
        else
        {
            item.DisplayName = data.DisplayNameEn;
            item.Description = data.DescriptionEn;
        }
        item.ApType                      = data.AppType;
        item.ThrowDexterity              = data.ThrowDexterity;
        item.WeaponBaseAttack            = data.BaseAttack;
        item.WeaponBaseDexterity         = data.Dexterity;
        item.WeaponBaseCritical          = data.Critical;
        item.WeaponBaseDexterityCritical = data.Critical;
        if (isRandomValue == false)
        {
            return(item);
        }
        QualifyInformation q = TableQualify.GetRandomName(data.Level);

        item.DisplayNameBefore      = q.Name;
        item.DisplayNameBeforeObjNo = q.ObjNo;
        item.StrengthValue          = CommonFunction.ConvergenceRandom(data.StrengthAddStart, data.StrengthAddContinue, data.StrengthnAddReduce);
        int optioncount = CommonFunction.ConvergenceRandom(data.OptionAddStart, data.OptionAddContinue, data.OptionAddReduce);
        int index       = 0;

        for (int i = 0; i < optioncount; i++)
        {
            //30回回して終わらなかったら強制終了
            if (index > 30)
            {
                break;
            }
            index++;
            uint       rnd    = CommonFunction.GetRandomUInt32();
            BaseOption newOpt = TableOptionCommon.GetValue(OptionBaseType.Weapon, rnd, data.OptionPowStart, data.OptionPowContinue, data.OptionPowReduce);

            //同じオプションがすでに含まれていたらもう一度算出
            if (CommonFunction.IsNull(newOpt) == true)
            {
                i--;
                continue;
            }
            BaseOption containOpt = item.Options.Find(o => o.ObjNo == newOpt.ObjNo);
            if (CommonFunction.IsNull(containOpt) == false)
            {
                i--;
                continue;
            }
            item.Options.Add(newOpt);
        }
        return(item);
    }
Beispiel #30
0
        public void SetUp(WeaponChance weapon)
        {
            gameObject.AddComponent <WeaponBase> ().type = (WeaponType)weapon.weaponType;

            WeaponBase wb = GetComponent <WeaponBase> ();

            blade  = transform.GetChild(0).gameObject;
            handle = transform.GetChild(1).gameObject;

            if (handle == null || blade == null)
            {
                Debug.LogError("BLADE OR HANDLE IS MISSING!");
                return;
            }

            handle.AddComponent <WeaponHandle> ();

            WeaponHandle wh = handle.GetComponent <WeaponHandle> ();

            wb.grabbable    = wh;
            wb.canParry     = weapon.canPary;
            wb.canBeParried = weapon.canBeParried;
            wb.addForceToRigidbodyFactor = weapon.addForceToRigidbodyFactor;

            wh.grabRigidbody       = wh.GetComponent <Rigidbody> ();
            wh.hideHandModelOnGrab = weapon.hideHandOnGrab;
            wh.isCurrentlyGrabbale = weapon.isCurrentlyGrabbable;
            wh.setPositionOnGrab   = weapon.setPositionOnGrab;
            wh.setRotationOnGrab   = weapon.setRotationOnGrab;

            DamagerRigidbody drb = blade.AddComponent <DamagerRigidbody> ();

            drb.scaleDamage   = weapon.scaleDamage;
            drb.canAlsoCut    = weapon.canAlsoCut;
            drb.bonusVelocity = weapon.bonusVelocity;
            drb.isDamaging    = weapon.isDamaging;
            drb.impaleDepth   = weapon.impaleDepth;
            drb.damageType    = (DamageType)weapon.damageType;

            handle.AddComponent <FootStepSound> ().soundEffectName    = "WeaponDrop";
            handle.GetComponent <FootStepSound> ().minVolumeToTrigger = 0.05f;

            try {
                if (transform.GetChild(2) != null)
                {
                    drb.heartStabPoint = transform.GetChild(2);

                    drb.impaledBreakForce             = weapon.impaleBreakForce;
                    drb.impaledZDamper                = weapon.impaleZDamper;
                    drb.impaledConnectedBodyMassScale = weapon.connectedBMass;
                }
            }
            catch {
                return;
            }

            /*
             * BezierConnector bc = blade.AddComponent<BezierConnector> ();
             *
             * bc.midPoints = new Transform[4] { blade.transform.GetChild(2), blade.transform.GetChild ( 2 ).GetChild(0), blade.transform.GetChild ( 2 ).GetChild(0).GetChild(0), blade.transform.GetChild ( 2 ).GetChild ( 0 ).GetChild ( 0 ).GetChild(0) };
             *
             * bc.orientTransforms = true;
             *
             * bc.end = blade.transform.GetChild(1);
             * bc.origin = blade.transform.GetChild(0);
             * bc.clampAngleTo = 30;
             */
            return;
        }
Beispiel #31
0
 public void SetUp(PlayerInfo pi, BulletManager bm, PlayerBase pb, WeaponBase wb)
 {
     playerBase = pb;
     playerInfo = pi;
     bulletManager = bm;
     weaponBase = wb;
     LoadSpecials();
 }
Beispiel #32
0
 private void Start()
 {
     currentWeapon       = Origin.GetComponent <Weaponer>().Weapon;
     currentWeapon.Shot += OnShot;
 }
Beispiel #33
0
    // ------------------------------------------------------------------ 
    // Desc: 
    // ------------------------------------------------------------------ 

    public void ChangeWeapon( WeaponBase.WeaponID _id ) {
        GameObject weaponGO = WeaponBase.Instance().GetWeapon(_id); 
        weaponGO.SetActiveRecursively(true);
        this.curWeapon = weaponGO; 
        this.curWeapon.transform.parent = this.weaponAnchor;
        this.curWeapon.transform.localPosition = Vector3.zero;
        this.curWeapon.transform.localRotation = Quaternion.identity;
        this.SetCurWeaponOwner();
    }
    public void Shoot()
    {
        if (InfinityAmmo)
        {
            Ammo = 1;
        }
        if (Ammo > 0)
        {
            if (Time.time > nextFireTime + FireRate)
            {
                nextFireTime = Time.time;
                torqueTemp   = TorqueSpeedAxis;
                Ammo        -= 1;
                Vector3    missileposition = this.transform.position;
                Quaternion missilerotate   = this.transform.rotation;
                if (MissileOuter.Length > 0)
                {
                    missilerotate   = MissileOuter [currentOuter].transform.rotation;
                    missileposition = MissileOuter [currentOuter].transform.position;
                }

                if (MissileOuter.Length > 0)
                {
                    currentOuter += 1;
                    if (currentOuter >= MissileOuter.Length)
                    {
                        currentOuter = 0;
                    }
                }

                if (Muzzle)
                {
                    GameObject muzzle = (GameObject)GameObject.Instantiate(Muzzle, missileposition, missilerotate);
                    muzzle.transform.parent = this.transform;
                    GameObject.Destroy(muzzle, MuzzleLifeTime);
                    if (MissileOuter.Length > 0)
                    {
                        muzzle.transform.parent = MissileOuter [currentOuter].transform;
                    }
                }

                for (int i = 0; i < NumBullet; i++)
                {
                    if (Missile)
                    {
                        Vector3 spread    = new Vector3(Random.Range(-Spread, Spread), Random.Range(-Spread, Spread), Random.Range(-Spread, Spread)) / 100;
                        Vector3 direction = this.transform.forward + spread;



                        GameObject bullet      = (GameObject)Instantiate(Missile, missileposition, missilerotate);
                        DamageBase damangeBase = bullet.GetComponent <DamageBase> ();
                        if (damangeBase)
                        {
                            damangeBase.Owner     = Owner;
                            damangeBase.TargetTag = TargetTag;
                        }
                        WeaponBase weaponBase = bullet.GetComponent <WeaponBase> ();
                        if (weaponBase)
                        {
                            weaponBase.Owner     = Owner;
                            weaponBase.Target    = target;
                            weaponBase.TargetTag = TargetTag;
                        }
                        bullet.transform.forward = direction;
                        if (RigidbodyProjectile)
                        {
                            if (bullet.GetComponent <Rigidbody>())
                            {
                                if (Owner != null && Owner.GetComponent <Rigidbody>())
                                {
                                    bullet.GetComponent <Rigidbody>().velocity = Owner.GetComponent <Rigidbody>().velocity;
                                }
                                bullet.GetComponent <Rigidbody>().AddForce(direction * ForceShoot);
                            }
                        }
                    }
                }
                if (Shell)
                {
                    Transform shelloutpos = this.transform;
                    if (ShellOuter.Length > 0)
                    {
                        shelloutpos = ShellOuter [currentOuter];
                    }

                    GameObject shell = (GameObject)Instantiate(Shell, shelloutpos.position, Random.rotation);
                    GameObject.Destroy(shell.gameObject, ShellLifeTime);
                    if (shell.GetComponent <Rigidbody>())
                    {
                        shell.GetComponent <Rigidbody>().AddForce(shelloutpos.forward * ShellOutForce);
                    }
                }

                if (SoundGun.Length > 0)
                {
                    if (audio)
                    {
                        audio.PlayOneShot(SoundGun [Random.Range(0, SoundGun.Length)]);
                    }
                }

                nextFireTime += FireRate;
            }
        }
    }
Beispiel #35
0
    public void ShowGameOver()
    {
        if (GameState == State.Dead)
        {
            return;
        }

        bool wasDeed = CurrentDeedData.Deed != DeedEnum.None;

        TextFloatingWeapon.Clear();
        GameProgressScript.Instance.Stop();
        ProjectileManager.Instance.StopAll();

        StartCoroutine(Server.Instance.UpdateStat("OrcsSaved", SaveGame.RoundScore));
        StartCoroutine(Server.Instance.UpdateStat("Kills", SaveGame.RoundKills));
        switch (CurrentGameModeData.GameMode)
        {
        case GameModeEnum.Nursery: UpdateStat("ScoreNursery", SaveGame.RoundScore); break;

        case GameModeEnum.Earth: UpdateStat("ScoreEarth", SaveGame.RoundScore); break;

        case GameModeEnum.Wind: UpdateStat("ScoreWind", SaveGame.RoundScore); break;

        case GameModeEnum.Fire: UpdateStat("ScoreFire", SaveGame.RoundScore); break;

        case GameModeEnum.Storm: UpdateStat("ScoreStorm", SaveGame.RoundScore); break;

        default: break;
        }

        //switch(CurrentDeedData.Deed)
        //{
        //    case DeedEnum.SnipersParadise: StartCoroutine(Server.Instance.UpdateStat("DeedSnipersParadise", CurrentDeedData.DeedCurrentScore)); break;
        //    case DeedEnum.MachinegunMadness: StartCoroutine(Server.Instance.UpdateStat("DeedTheEnd", CurrentDeedData.DeedCurrentScore)); break;
        //    case DeedEnum.LittleMonsters: StartCoroutine(Server.Instance.UpdateStat("DeedLittleMonsters", CurrentDeedData.DeedCurrentScore)); break;
        //    case DeedEnum.WhiteWalkers: StartCoroutine(Server.Instance.UpdateStat("DeedWhiteWalkers", CurrentDeedData.DeedCurrentScore)); break;
        //    default: break;
        //}

        float roundTime    = Time.time - roundStartTime_;
        int   roundSeconds = Mathf.RoundToInt(roundTime);

        StartCoroutine(Server.Instance.UpdateStat("RoundSeconds", roundSeconds));

        int bestScore = SaveGame.Members.GetCounter(GameCounter.Max_Score_Any);

        TextGameOverOrcsSaved.text     = string.Format("{0}", SaveGame.RoundScore);
        TextGameOverOrcsSavedBest.text = string.Format("{0}", bestScore);

        TextDeedScore.text           = string.Format("{0} / {1}", CurrentDeedData.DeedCurrentScore, CurrentDeedData.UpdatedKillReq);
        TextGameOverDeedScore.text   = TextDeedScore.text;
        TextGameOverDeedComment.text = CurrentDeedData.DeedComplete ?
                                       "Victory! Your Heroic Feat Will Be Remembered!" : "Defeat. Your Heroic Efforts Were In Vain.";
        TextGameOverDeedComment.color = CurrentDeedData.DeedComplete ? Color.green : Color.red;

        if (wasDeed && CurrentDeedData.DeedComplete)
        {
            SaveGame.Members.SetCounter(CurrentDeedData.CompletionCounter, 1);
        }

        bool newRecord = bestScore > roundStartBestScore_;

        TextNewRecord.GetComponent <TextBlinkScript>().enabled = newRecord;
        TextNewRecord.enabled = newRecord;

        CanvasGameOverDefault.enabled = !wasDeed;
        CanvasGameOverDeed.enabled    = wasDeed;

        TextRoundEndUnlocks.enabled = RoundUnlockCount > 0;
        if (RoundUnlockCount > 0)
        {
            TextRoundEndUnlocks.text = Unlocks.LatestUnlockText;
        }
        else
        {
            // Show progress towards next weapon (wheree counter is Score_Any_Sum)
            var nextWeapons = GameEvents.WeaponUnlockInfo.Where(
                wep => wep.Counter == GameCounter.Score_Any_Sum && SaveGame.Members.GetCounter(wep.Counter) < wep.Requirement
                ).OrderBy(wep => wep.Requirement).ToList();

            if (nextWeapons.Count > 0)
            {
                var nextWep = nextWeapons[0];
                int needed  = nextWep.Requirement - SaveGame.Members.GetCounter(nextWep.Counter);
                TextRoundEndUnlocks.enabled = true;
                TextRoundEndUnlocks.text    = string.Format("Save {0} More To Unlock Next Weapon: {1}!", needed, WeaponBase.WeaponDisplayName(nextWep.Type));
            }
        }

        SaveGame.UpdateFromRound(roundSeconds, reset: true);
        SaveGame.Save();

        CanvasDead.gameObject.SetActive(true);
        CanvasIntro.gameObject.SetActive(false);

        GameState = State.Dead;
    }
 public void GotHit(WeaponBase attacker)
 {
     Health -= attacker.Damage;
 }
    public virtual AttackState Attack(ManageDungeon dun, BaseCharacter target, BaseCharacter attacker, int power, AttackInformation atinf)
    {
        int damage = 0;

        atinf.AddTarget(target);

        //声を鳴らす
        atinf.AddVoice(attacker.VoiceAttack());

        //攻撃の命中判定
        if (CommonFunction.IsRandom(WeaponDexterity) == true)
        {
            //行動タイプを設定
            atinf.SetBehType(BehaviorType.Attack);

            //命中したら
            atinf.AddHit(target, true);

            //声を鳴らす
            atinf.AddVoice(target.VoiceDefence());

            //サウンドを鳴らす
            atinf.AddSound(GetAttackHitSound());

            BaseOption[] atoptions = attacker.Options;
            BaseOption[] tgoptions = target.Options;

            //与ダメージを計算
            damage = CalcDamage(dun, attacker, target, power, atoptions, tgoptions, 1);

            //スコア関連値の更新
            if (target.Type == ObjectType.Enemy)
            {
                TotalDamage += damage;
                if (ScoreInformation.Info.MostUseWeaponDamage < TotalDamage)
                {
                    ScoreInformation.Info.MostUseWeaponDamage = TotalDamage;
                    ScoreInformation.Info.MostUseWeaponName   = DisplayNameNormal;
                }

                ScoreInformation.Info.AddScore(damage);
            }

            //atinf.AddDamage(target.Name, damage);

            ////ヒットメッセージ
            //atinf.AddMessage(
            //    target.GetMessageAttackHit(this.DisplayNameInMessage, damage));

            ////ダメージ判定
            //AttackState atState = target.AddDamage(damage);
            //ダメージ追加
            AttackState atState = CommonFunction.AddDamage(atinf, attacker, target, damage);

            //ガラスアイテム判定
            WeaponBase atw = attacker.EquipWeapon;
            foreach (BaseOption op in atw.Options)
            {
                if (op.IsBreak() == true)
                {
                    atinf.AddSound(SoundInformation.SoundType.Break);

                    atinf.AddMessage(
                        string.Format(CommonConst.Message.BreakItem, atw.DisplayNameInMessage));

                    atw.ForceRemoveEquip(attacker);
                    PlayerCharacter.RemoveItem(atw);
                }
            }
            ShieldBase tgs = target.EquipShield;
            foreach (BaseOption op in tgs.Options)
            {
                if (op.IsBreak() == true)
                {
                    atinf.AddSound(SoundInformation.SoundType.Break);

                    atinf.AddMessage(
                        string.Format(CommonConst.Message.BreakItem, tgs.DisplayNameInMessage));

                    tgs.ForceRemoveEquip(target);
                    PlayerCharacter.RemoveItem(tgs);
                }
            }


            //対象が死亡したら
            if (atState == AttackState.Death)
            {
                atinf.AddKillList(target);

                atinf.AddMessage(
                    target.GetMessageDeath(target.HaveExperience));
            }
            else
            {
                //atinf.IsDeath.Add(target.Name, false);

                addabnormal.Clear();
                prevents.Clear();
                foreach (StateAbnormal val in CommonFunction.StateAbnormals)
                {
                    prevents.Add(val, 0);
                    addabnormal.Add(val, AddAbnormalProb[val]);
                }

                int opab = 0;
                //オプションの付加値設定
                foreach (BaseOption o in atoptions)
                {
                    int ab = o.SetAbnormalAttack(addabnormal);
                    opab = opab | ab;
                }

                int tarabn = AddAbnormal | opab;

                if (tarabn != 0)
                {
                    //オプションによる状態異常の取得
                    //foreach (StateAbnormal val in CommonFunction.StateAbnormals)
                    //{
                    //    addabnormal.Add(val, 0);
                    //}

                    //オプションの抵抗値設定
                    foreach (BaseOption o in tgoptions)
                    {
                        o.SetAbnormalPrevent(prevents);
                    }

                    int abn = 0;
                    //状態異常の付与
                    foreach (StateAbnormal val in CommonFunction.StateAbnormals)
                    {
                        int abnormal = (int)val & tarabn;

                        //対象の状態異常を処理
                        if (abnormal != 0)
                        {
                            //float prob = prevents[val] > AddAbnormalProb[val] ? prevents[val] : AddAbnormalProb[val];
                            //状態異常付与が成功したとき
                            if (CommonFunction.IsRandom(addabnormal[val]) == true)
                            {
                                //抵抗に成功したとき
                                if (CommonFunction.IsRandom(prevents[val]) == true)
                                {
                                }
                                else
                                {
                                    int addstate = target.AddStateAbnormal(abnormal);
                                    if (addstate != 0)
                                    {
                                        abn += abnormal;
                                        //atinf.AddAbnormal(target, abnormal);

                                        atinf.AddMessage(
                                            CommonFunction.GetAbnormalMessage(val, target));
                                    }
                                }
                            }
                        }
                    }
                    if (abn != 0)
                    {
                        atinf.AddEffect(EffectBadSmoke.CreateObject(target));
                        atinf.AddAbnormal(target, abn);
                    }
                }
            }

            //エフェクトをかける
            this.AttackEffect(target, attacker, damage.ToString(), AttackState.Hit, atinf);

            return(atState);
        }
        else
        {
            //外れた場合
            atinf.AddHit(target, false);

            EffectDamage d = EffectDamage.CreateObject(target);
            d.SetText("Miss", AttackState.Miss);
            atinf.AddEffect(d);

            atinf.AddSound(GetAttackMissSound());

            atinf.AddMessage(
                target.GetMessageAttackMiss());
            return(AttackState.Miss);
        }
    }
Beispiel #38
0
 public void SwapWeapon(WeaponBagPos weaponType, WeaponBase weapon)
 {
     SwapWeapon((int)weaponType, weapon);
 }
Beispiel #39
0
 public static bool ReportAndValidateAttack(uLink.NetworkPlayer player, WeaponBase weapon, Vector3 fromPos, Vector3 dir, uLink.NetworkMessageInfo info)
 {
     return(true);
 }
Beispiel #40
0
    void Update()
    {
        RaycastHit hit;
        Vector3    position = shootPoint.position;

        position.y += 1;                // Adjust height differences

        // Debug.DrawRay(position, transform.TransformDirection(Vector3.forward * detectRange), Color.red);
        if (Physics.Raycast(position, transform.TransformDirection(Vector3.forward * detectRange), out hit, detectRange))
        {
            if (hit.transform.tag == "Shop")
            {
                Shop     shop          = hit.transform.GetComponent <Shop>();
                ShopType shopType      = shop.shopType;
                string   shopTitle     = shop.title;
                string   shopDesc      = shop.description;
                int      shopPrice     = shop.price;
                bool     isPurchasable = true;

                WeaponManager weaponManager = transform.Find("WeaponHolder").GetComponent <WeaponManager>();
                WeaponBase    weaponBase    = weaponManager.currentWeaponGO.GetComponent <WeaponBase>();
                Weapon        weapon        = weaponManager.currentWeapon;

                if (shopType == ShopType.AMMO)
                {
                    shopPrice     = GetAmmoPrice(weapon);
                    shopText.text = shopTitle + "\n(" + shopPrice + "$)\n\n" + shopDesc + "\n\n";
                }
                else if (shopType == ShopType.UPGRADE_DAMAGE)
                {
                    int upgraded = weaponBase.upgradeDamage;

                    if (upgraded < 10)
                    {
                        shopPrice     = GetUpgradePrice(weaponManager.currentWeapon, upgraded);
                        shopText.text = shopTitle + " Lv" + (upgraded + 1) + "\n(" + shopPrice + "$)\n\n" + shopDesc + "\n\n";
                    }
                    else
                    {
                        isPurchasable = false;
                        shopText.text = "Your weapon is fully upgraded.";
                    }
                }
                else if (shopType == ShopType.UPGRADE_RELOAD)
                {
                    int upgraded = weaponBase.upgradeReload;

                    if (upgraded < 10)
                    {
                        shopPrice     = GetUpgradePrice(weaponManager.currentWeapon, upgraded);
                        shopText.text = shopTitle + " Lv" + (upgraded + 1) + "\n(" + shopPrice + "$)\n\n" + shopDesc + "\n\n";
                    }
                    else
                    {
                        isPurchasable = false;
                        shopText.text = "Your weapon is fully upgraded.";
                    }
                }
                else if (shopType == ShopType.UPGRADE_RECOIL)
                {
                    int upgraded = weaponBase.upgradeRecoil;

                    if (upgraded < 10)
                    {
                        shopPrice     = GetUpgradePrice(weaponManager.currentWeapon, upgraded);
                        shopText.text = shopTitle + " Lv" + (upgraded + 1) + "\n(" + shopPrice + "$)\n\n" + shopDesc + "\n\n";
                    }
                    else
                    {
                        isPurchasable = false;
                        shopText.text = "Your weapon is fully upgraded.";
                    }
                }
                else
                {
                    shopText.text = shopTitle + "\n(" + shopPrice + "$)\n\n" + shopDesc + "\n\n";
                }

                if (isPurchasable && (Input.GetButtonDown("Fire3") || Input.GetKeyDown(KeyCode.X)))
                {
                    nextFire = myTime + fireDelta;

                    FundSystem fundSystem = transform.parent.GetComponent <FundSystem>();
                    int        fund       = fundSystem.GetFund();

                    if (fund < shopPrice)
                    {
                        PrintWarning("Not enough money!");
                    }
                    else
                    {
                        bool wasPurchased = true;

                        if (shopType == ShopType.AMMO)
                        {
                            weaponBase.bulletsLeft = weaponBase.startBullets + weaponBase.bulletsPerMag;
                            weaponBase.UpdateAmmoText();
                        }
                        else if (shopType == ShopType.WEAPON_MP5K)
                        {
                            if (!weaponManager.HasWeapon(Weapon.MP5K))
                            {
                                BuyWeapon(Weapon.MP5K);
                            }
                            else
                            {
                                wasPurchased = false;
                                PrintWarning("You already have weapon.");
                            }
                        }
                        else if (shopType == ShopType.WEAPON_AKM)
                        {
                            if (!weaponManager.HasWeapon(Weapon.AKM))
                            {
                                BuyWeapon(Weapon.AKM);
                            }
                            else
                            {
                                wasPurchased = false;
                                PrintWarning("You already have weapon.");
                            }
                        }
                        else if (shopType == ShopType.WEAPON_M870)
                        {
                            if (!weaponManager.HasWeapon(Weapon.M870))
                            {
                                BuyWeapon(Weapon.M870);
                            }
                            else
                            {
                                wasPurchased = false;
                                PrintWarning("You already have weapon.");
                            }
                        }
                        else if (shopType == ShopType.UPGRADE_DAMAGE)
                        {
                            if (weaponBase.upgradeDamage >= 10)
                            {
                                wasPurchased = false;
                                PrintWarning("Your weapon is fully upgraded.");
                            }
                            else
                            {
                                UpgradeWeapon(weaponBase, ShopType.UPGRADE_DAMAGE);
                            }
                        }
                        else if (shopType == ShopType.UPGRADE_RELOAD)
                        {
                            if (weaponBase.upgradeReload >= 10)
                            {
                                wasPurchased = false;
                                PrintWarning("Your weapon is fully upgraded.");
                            }
                            else
                            {
                                UpgradeWeapon(weaponBase, ShopType.UPGRADE_RELOAD);
                            }
                        }
                        else if (shopType == ShopType.UPGRADE_RECOIL)
                        {
                            if (weaponBase.upgradeRecoil >= 10)
                            {
                                wasPurchased = false;
                                PrintWarning("Your weapon is fully upgraded.");
                            }
                            else
                            {
                                UpgradeWeapon(weaponBase, ShopType.UPGRADE_RECOIL);
                            }
                        }
                        else
                        {
                            wasPurchased = false;
                        }

                        if (wasPurchased)
                        {
                            fundSystem.TakeFund(shopPrice);
                            SoundManager soundManager = transform.Find("SoundManager").GetComponent <SoundManager>();
                            soundManager.Play(purchasedSound);
                        }
                    }

                    nextFire = nextFire - myTime;
                    myTime   = 0.0F;
                }
            }
        }
        else
        {
            shopText.text = "";
        }
    }
Beispiel #41
0
    public void Load(string file)
    {
        string s = file;

        if (!string.IsNullOrEmpty(file))
        {
            //查看此物体属于什么,A:武器 B:道具 C:镖物
            if (ItemInfo == null)
            {
                for (int i = 0; i < MenuResLoader.Instance.Info.Count; i++)
                {
                    if (MenuResLoader.Instance.Info[i].model != "0" && 0 == string.Compare(MenuResLoader.Instance.Info[i].model, s, true))
                    {
                        ApplyPrev(MenuResLoader.Instance.Info[i]);
                        break;
                    }
                    string rh  = s.ToUpper();
                    string rh2 = MenuResLoader.Instance.Info[i].model.ToUpper();
                    if (rh2.StartsWith(rh))
                    {
                        s = MenuResLoader.Instance.Info[i].model;
                        ApplyPrev(MenuResLoader.Instance.Info[i]);
                        break;
                    }
                }
                //不是一个Meteor.res里的物件
                if (ItemInfo == null)
                {
                    List <ItemBase> its = GameData.itemMng.GetFullRow();
                    for (int i = 0; i < its.Count; i++)
                    {
                        if (its[i].MainType == 1)
                        {
                            WeaponBase weapon = WeaponMng.Instance.GetItem(its[i].UnitId);
                            if (weapon.WeaponR == s)
                            {
                                ItemInfoEx = its[i];
                                break;
                            }
                        }
                    }
                }
            }

            //证明此物品不是可拾取物品
            gameObject.layer      = (ItemInfo != null || ItemInfoEx != null) ?  LayerMask.NameToLayer("Trigger") : LayerMask.NameToLayer("Scene");
            root.gameObject.layer = gameObject.layer;
            //箱子椅子桌子酒坛都不允许为场景物品.
            WsGlobal.ShowMeteorObject(s, root);
            DesFile fIns = DesLoader.Instance.Load(s);
            //把子物件的属性刷到一起.
            for (int i = 0; i < fIns.SceneItems.Count; i++)
            {
                LoadCustom(fIns.SceneItems[i].name, fIns.SceneItems[i].custom);
            }

            player = GetComponent <FMCPlayer>();
            if (player == null)
            {
                player = gameObject.AddComponent <FMCPlayer>();
            }
            player.Init(s);
            if (player.frames == null)
            {
                Destroy(player);
                player = null;
            }
        }
    }
Beispiel #42
0
 public static void Write(this NetworkWriter writer, WeaponBase weapon)
 {
     writer.WriteByte((byte)weapon.WeaponType);
     weapon.Serialize(writer);
 }
Beispiel #43
0
 void SetWeapon(WeaponType type)
 {
     Weapon = WeaponBase.GetWeapon(type);
     weaponTransform_.localScale = Weapon.Scale;
     weaponRenderer_.sprite      = Weapon.Sprite;
 }
 public void ChangeWeapon(WeaponBase gun)
 {
     currentWeapon = gun;
     currentWeaponSprite.sprite = gun.PlayerSprite;
     a.runtimeAnimatorController = gun.PlayerAnimator;
 }
Beispiel #45
0
    // ------
    protected override void OnUpdate()
    {
        base.OnUpdate();

        if (Camera.main == null)
        {
            return;
        }

        AgentHuman player     = Owner.LocalPlayer.Owner;
        BlackBoard blackBoard = player.BlackBoard;

        if (player.LastHitTime + 0.15f > Time.timeSinceLevelLoad)
        {
            m_CrosshairHit.Widget.Show(true, true);
        }
        else
        {
            m_CrosshairHit.Widget.Show(false, true);
        }

        WeaponBase weapon = player.WeaponComponent.GetCurrentWeapon();

        if (!weapon || weapon.PreparedForFireProgress < 0 || !player.IsAlive)
        {
            if (m_PrepareForFire.IsVisible())
            {
                m_PrepareForFire.Show(false, true);
            }
        }
        else
        {
            if (!m_PrepareForFire.IsVisible())
            {
                m_PrepareForFire.Show(true, true);
            }
            float   progress = weapon.PreparedForFireProgress;
            Color   color    = Color.white * (1 - progress) + Color.green * progress;
            Vector3 offset   = new Vector3(75 + 70 * (1 - progress), 0, 0);
            Vector3 basePos  = m_PrepareForFire.transform.localPosition;

            m_PrepareForFireA.Color = color;
            m_PrepareForFireB.Color = color;
            m_PrepareForFireA.transform.localPosition = basePos - offset;
            m_PrepareForFireB.transform.localPosition = basePos + offset;
            m_PrepareForFire.SetModify(true);
        }

        const float crosshairDistance = 200.0f;
        //do jake vzdalenosti testujeme kolizi zda mirime na enemy (todo: mozna pouzit konstantu z UpdateIdealFireDir)
        bool aimingHit      = false;
        bool showEnemyLabel = false;
        //test collision in aiming sight
        Ray        ray  = Camera.main.ScreenPointToRay(new Vector2(Screen.width / 2, Screen.height / 2));
        LayerMask  mask = (ObjectLayerMask.Default | ObjectLayerMask.PhysicsMetal | ObjectLayerMask.Ragdoll);
        Vector3    hitPoint;
        GameObject go    = CollisionUtils.FirstCollisionOnRay(ray, crosshairDistance, player.GameObject, out hitPoint, mask);
        Agent      agent = null;

        if (go)
        {
            agent = GameObjectUtils.GetFirstComponentUpward <Agent>(go);
            if (!agent || (agent == Player.LocalInstance.Owner) || !agent.IsAlive || agent.IsFriend(player))
            {
                agent = null;
            }
        }
        if (!agent)
        {
            mask = ObjectLayerMask.Ragdoll;
            go   = CollisionUtils.FirstSphereCollisionOnRay(ray, 0.6f, crosshairDistance, player.GameObject, out hitPoint, mask);
            if (go)
            {
                mask          = ObjectLayerMask.Default | ObjectLayerMask.PhysicsMetal | ObjectLayerMask.Ragdoll;
                ray.direction = hitPoint - ray.origin;
                GameObject go2 = CollisionUtils.FirstCollisionOnRay(ray, crosshairDistance, player.GameObject, out hitPoint, mask);                 // to be accurate
                if (go2)
                {
                    agent = GameObjectUtils.GetFirstComponentUpward <Agent>(go2);
                    if (!agent || (agent == Player.LocalInstance.Owner) || !agent.IsAlive || agent.IsFriend(player))
                    {
                        agent = null;
                    }
                }
            }
        }

        if (agent)
        {
            //is it enemy?
            //Sem pridavat dalsi typy enemacu co nejsou podedene z agenta
            Agent a = GameObjectUtils.GetFirstComponentUpward <Agent>(go);
            if (a && (a != Player.LocalInstance.Owner) && a.IsAlive && !a.IsFriend(player))
            {
                aimingHit = true;
                PlayerPersistantInfo ppi = PPIManager.Instance.GetPPI(a.networkView.owner);
                if (ppi != null)
                {
                    SetTextAndAdjustBackground(ppi.NameForGui, m_EnemyLabelName, m_EnemyLabel, m_EnemyLabelOrigWidth, m_EnemyLabelNameOrigScale);
                    showEnemyLabel = true;
                }
                E_Team enemyTeam = (ppi != null) ? ppi.Team : E_Team.None;
                if (Client.Instance.GameState.GameType == E_MPGameType.DeathMatch)
                {
                    enemyTeam = E_Team.Bad;
                }
                m_EnemyLabel.Color          = ZoneControlFlag.Colors[enemyTeam];
                m_CrosshairHit.Widget.Color = ZoneControlFlag.Colors[E_Team.Bad];
                //m_Crosshair[(int)E_CrosshairType.Target].Widget.Color = ZoneControlFlag.Colors[E_Team.Bad];
                //foreach (GUIBase_Widget widget in m_CrosshairTargetChilds)
                //	widget.Color = ZoneControlFlag.Colors[E_Team.Bad];
            }
        }
        m_EnemyLabel.Show(showEnemyLabel, true);

        if (aimingHit || blackBoard.Desires.MeleeTarget && player.CanMelee())
        {
            ShowCrosshair(E_CrosshairType.Target);
        }
        else
        {
            ShowCrosshair(E_CrosshairType.Normal);
        }
    }
Beispiel #46
0
 public void BindSwordToX()
 {
     DWPN = SWORD;
 }
Beispiel #47
0
 public WeaponPickedEvent(WeaponBase _weapon, int _dropIndex)
 {
     weapon    = _weapon;
     dropIndex = _dropIndex;
 }
 public static void HitBoss(WeaponBase weapon)
 {
     var random = new Random();
     var damage = weapon.DoSomeDamage(random.Next(0, 100));
 }
Beispiel #49
0
    // <<<MOVEMENT...>>> //
    protected void Movement()
    {
        if (Input.GetKeyDown(keyFire)) {
            weaponHandling.fire(direction);
            weaponHandling.fireKeyUp = false;
        }
        if (Input.GetKey(keyFire))
        {
            if (weaponHandling.activeWeapon.weaponType == WeaponEnum.MP40 )
            {
                weaponHandling.fire(direction);
            }
        }
        if (Input.GetKeyUp(keyFire))
        {
            weaponHandling.fireKeyGotUp();
        }

        if (Input.GetKeyDown(keySwitchWeapon))
        {
            weaponHandling.SwitchWeapon();
        }

        if (Input.GetKeyDown(keyUp) && !PressedKeysContains(keyUp))
        {

            pressedKeys.Add(keyUp);

        }
        else if (Input.GetKeyDown(keyLeft) && !PressedKeysContains(keyLeft))
        {
            teleport = false;
            pressedKeys.Add(keyLeft);

        }
        else if (Input.GetKeyDown(keyDown) && !PressedKeysContains(keyDown))
        {
            teleport = false;
            pressedKeys.Add(keyDown);
        }
        else if (Input.GetKeyDown(keyRight) && !PressedKeysContains(keyRight))
        {
            teleport = false;
            pressedKeys.Add(keyRight);
        }

        //actualy moving
        if (GetLastPressed() == keyUp)
        {
            if (!teleport)
            {
                rb2d.velocity = up*speed;
                direction = up;
                UpdateAnimatorState(AnimatorStateEnum.walkUp);
            }
            else
            {
                rb2d.velocity = down * speed;
                direction = down;
                UpdateAnimatorState(AnimatorStateEnum.walkDown);
            }
        }
        else if (GetLastPressed() == keyLeft)
        {
            rb2d.velocity = left * speed;
            direction = left;
            UpdateAnimatorState(AnimatorStateEnum.walkLeft);

        }
        else if (GetLastPressed() == keyDown)
        {
            rb2d.velocity = down * speed;
            direction = down;
            UpdateAnimatorState(AnimatorStateEnum.walkDown);

        }
        else if (GetLastPressed() == keyRight)
        {
            rb2d.velocity = right * speed;
            direction = right;
            UpdateAnimatorState(AnimatorStateEnum.walkRight);

        }
        else
        {
            rb2d.velocity = stop;
            UpdateAnimatorState(AnimatorStateEnum.stop);
        }

        if (Input.GetKeyUp(keyUp) || Input.GetKeyUp(keyLeft) ||
            Input.GetKeyUp(keyDown) || Input.GetKeyUp(keyRight))
        {
            rb2d.velocity = stop;
            if (Input.GetKeyUp(keyUp))
            {
                RemoveKeyPressed(keyUp);
                teleport = false;

            }
            if (Input.GetKeyUp(keyLeft))
            {
                RemoveKeyPressed(keyLeft);
            }
            if (Input.GetKeyUp(keyDown))
            {
                RemoveKeyPressed(keyDown);
            }
            if (Input.GetKeyUp(keyRight))
            {
                RemoveKeyPressed(keyRight);
            }
        }

        // checking if weapon was switched last frame for hud
        if (prevWeapon == activeWeapon)
        {
            weaponHandling.switchedWeapon = false;
        }
        prevWeapon = weaponHandling.activeWeapon;

        CheckPressedKeys();

        UpdateDirection();
    }
Beispiel #50
0
    public BulletBase CreateBullet( WeaponBase _weapon, WeaponFirePoint _firePoint, float _damageScale,
	                               bool _local, float _sentTime )
    {
        BulletDescriptor descriptor = BulletDescriptorManager.instance.GetDescOfType( _weapon.weaponType );

        if ( descriptor.smartBullet && !_local )
        {
            return null;
        }

        BulletBase bulletScript = null;
        GameObject bulletObj = null;
        if ( descriptor.smartBullet == false )
        {
            bulletScript = this.bulletDictionary[ _weapon.weaponType ].GetAvailableBullet( -1, -1 );

            if ( bulletScript == null )
            {
                DebugConsole.Error( "Error shooting bullet of type \"" + _weapon.weaponType + "\"", this );
                return null;
            }

            bulletObj = bulletScript.gameObject;
            bulletObj.transform.position = _firePoint.transform.position;
            bulletObj.transform.rotation = Quaternion.LookRotation( _firePoint.transform.forward );

            bulletObj.SetActive( true );
            bulletScript.Reset();
            bulletScript.enabled = true;
        }
        else // Smart bullets
        {
        #if UNITY_EDITOR
            if ( Network.peerType == NetworkPeerType.Disconnected )
            {
                bulletObj = GameObject.Instantiate(
                    descriptor.prefab,
                    _firePoint.transform.position,
                    Quaternion.LookRotation( _firePoint.transform.forward ) ) as GameObject;
            }
            else
        #endif
            {
                bulletObj = Network.Instantiate(
                    descriptor.prefab,
                    _firePoint.transform.position,
                    Quaternion.LookRotation( _firePoint.transform.forward ),
                    0) as GameObject;
            }
            bulletScript = bulletObj.GetComponent<BulletBase>();

            BaseHealth bulletHealth = bulletObj.GetComponent<BaseHealth>();
            bulletHealth.Owner = _weapon.source.health.Owner;
        }

        bulletScript.state = BulletBase.BULLET_STATE.ACTIVE_OWNED;
        bulletScript.damageScale = _damageScale;
        bulletScript.source = _weapon.source;
        if ( _weapon.source.GetComponent<Collider>() != null )
        {
            Physics.IgnoreCollision( bulletObj.GetComponent<Collider>(), _weapon.source.GetComponent<Collider>() );
        }

        // Bullet spread
        if ( _weapon.weaponDesc.spread != 0.0f )
        {
            System.Random newRand = new System.Random( (int)( _sentTime * 1000.0f ) );
            Vector3 perp = new Vector3( (float)(newRand.NextDouble() * 2.0f - 1.0f),
                                        (float)(newRand.NextDouble() * 2.0f - 1.0f), 0.0f );
            perp.Normalize();
            perp = bulletObj.transform.TransformDirection( perp );
            bulletObj.transform.Rotate( perp, UnityEngine.Random.Range( -_weapon.weaponDesc.spread, _weapon.weaponDesc.spread ) );
        }

        /*
        // Tell everyone else to fire the bullet
        if ( descriptor.smartBullet == false
          && Network.peerType != NetworkPeerType.Disconnected )
        {
            GameNetworkManager.instance.SendShootBulletMessage(
               _weapon.weaponType,
               bulletScript.index,
               _firePoint.transform.position,
               bulletObj.transform.rotation );
        }

        */
        if ( !_local && !descriptor.smartBullet )
        {
            bulletScript.Reset();
            bulletScript.state = BulletBase.BULLET_STATE.ACTIVE_NOT_OWNED;

            bulletObj.GetComponent<Collider>().enabled = false;

            float delta = (float)Network.time - _sentTime;
            Vector3 offset = bulletObj.transform.forward * descriptor.moveSpeed * delta;
            bulletObj.transform.Translate( offset );
        }

        bulletScript.OnShoot();
        _weapon.source.OnBulletCreated( _weapon, bulletScript );

        // Tell everyone else about the owner of this bullet
        if ( descriptor.smartBullet == true
          && Network.peerType != NetworkPeerType.Disconnected )
        {
            SeekingBullet seekingScript = descriptor.prefab.GetComponent<SeekingBullet>();
            BaseHealth target = seekingScript != null ? bulletObj.GetComponent<SeekingBullet>().target : null;
            NetworkViewID viewID = target != null ? target.GetComponent<NetworkView>().viewID : NetworkViewID.unassigned;

            GameNetworkManager.instance.SendSmartBulletInfoRPC(
                  bulletObj.GetComponent<NetworkView>().viewID,
                  GamePlayerManager.instance.myPlayer.id,
                  viewID );
        }

        return bulletScript;
    }