コード例 #1
0
ファイル: NetworkAmmo.cs プロジェクト: antiNT2/IsoSpell-V
    private void Start()
    {
        if (GameManager.instance.isInOnlineMultiplayer == false)
        {
            this.enabled = false;
            return;
        }

        damageScript   = GetComponent <DamageZone>();
        velocityScript = GetComponent <AmmoVelocity>();

        print(damageScript.playerThatShotThis);

        if (damageScript.playerThatShotThis == NetworkPlayer.localPlayer.gameObject) //this means that we spawned this bullet locally
        {
            GetSettings();
            NetworkPlayer.localPlayer.CmdSpawnBullet(bulletId, NetworkPlayer.localPlayer.gameObject, settings);
        }
        else //this bullet has just been spawned from the server
        {
            damageScript.dontDoDamage = true; //the damage has already been taken care of
            if (settings.playerWhoSpawnedThis == NetworkPlayer.localPlayer.gameObject)
            {
                this.gameObject.SetActive(false);
                return;
            }
            SetSettings();
        }
    }
コード例 #2
0
ファイル: ClassicGunShoot.cs プロジェクト: antiNT2/IsoSpell-V
    public void ShootAmmo(float aimAngle)
    {
        GameObject spawnedAmmo = Instantiate(ammo);

        spawnedAmmo.transform.position = CustomFunctions.GetAmmoSpawnPos(playerController.gameObject);

        spawnedAmmo.transform.rotation = Quaternion.Euler(0, 0, aimAngle * Mathf.Rad2Deg);

        AmmoVelocity ammoVelocity = spawnedAmmo.GetComponent <AmmoVelocity>();

        ammoVelocity.direction = Vector2.right;
        ammoVelocity.speed     = GameManager.instance.GetPlayerWeapon(playerController.gameObject).ammoVelocity;

        DamageZone ammoDamage = spawnedAmmo.GetComponent <DamageZone>();

        ammoDamage.ignorePlayer             = playerController.gameObject;
        ammoDamage.playerThatShotThis       = playerController.gameObject;
        ammoDamage.damage                   = GameManager.instance.GetPlayerWeapon(playerController.gameObject).damage;
        ammoDamage.destroyOnWallCollision   = destroyAmmoOnWallCollision;
        ammoDamage.destroyOnPlayerCollision = true;
        CustomFunctions.SetTrailColor(spawnedAmmo.GetComponent <TrailRenderer>(), GameManager.instance.GetPlayerId(playerController.gameObject));
        Physics2D.IgnoreCollision(spawnedAmmo.GetComponent <Collider2D>(), playerController.GetComponent <Collider2D>());

        Destroy(spawnedAmmo, 10f);
    }
コード例 #3
0
 private void Start()
 {
     ammoDamageZone = GetComponent <DamageZone>();
     ammoVelocity   = GetComponent <AmmoVelocity>();
     ammoDamageZone.OnWallCollision += BounceAmmo;
 }