예제 #1
0
        private void OnDetachableGameObjectImpact(SpecialAttack attack)
        {
            attack.UpdateDetachableShadowAnimator(SpecialAttackDetachableObjectState.OnGround);
            if (attack.StarshipDetachableGameObject.transform.parent != null)
            {
                attack.StarshipDetachableGameObject.transform.parent = null;
            }
            Vector3 position = attack.StarshipDetachableGameObject.transform.position;

            attack.StarshipDetachableGameObject.transform.position = Vector3.Scale(position, Vector3.one - Vector3.up);
        }
예제 #2
0
        private void OnAttachmentLoadedSuccess(object asset, object cookie)
        {
            GameObject    gameObject    = asset as GameObject;
            SpecialAttack specialAttack = (SpecialAttack)cookie;

            specialAttack.StarshipDetachableGameObject = gameObject;
            specialAttack.SetupDetachableShadowAnimator();
            Transform attachTransform = GameUtils.FindAssetMetaDataTransform(specialAttack.StarshipGameObject, "locator_attach");

            this.AttachGameObject(attachTransform, gameObject, true);
            specialAttack.UpdateDetachableShadowAnimator(SpecialAttackDetachableObjectState.Attached);
        }
예제 #3
0
        private void SpawnProjectile(uint id, object cookie)
        {
            SpecialAttack specialAttack = (SpecialAttack)cookie;

            StaRTS.Utils.Diagnostics.Logger logger = Service.Logger;
            if (specialAttack == null)
            {
                logger.Error("SpawnProjectile: specialAttack is null");
                this.SendSpecialAttackFired(null);
                return;
            }
            if (specialAttack.GetGunLocator() == null)
            {
                logger.Error("SpawnProjectile: specialAttack.GetGunLocator() is null " + specialAttack.VO.Uid);
                this.SendSpecialAttackFired(specialAttack.VO);
                return;
            }
            if (specialAttack.GetGunLocator().transform == null)
            {
                logger.Error("SpawnProjectile: specialAttack.GetGunLocator().transform is null " + specialAttack.VO.Uid);
                this.SendSpecialAttackFired(specialAttack.VO);
                return;
            }
            Vector3 position = specialAttack.GetGunLocator().transform.position;

            if (specialAttack.VO == null)
            {
                logger.Error("SpawnProjectile: specialAttack.VO is null");
                this.SendSpecialAttackFired(specialAttack.VO);
                return;
            }
            float num      = specialAttack.VO.NumberOfAttackers;
            int   quantity = (int)((float)specialAttack.VO.Damage / num);

            specialAttack.ApplySpecialAttackBuffs(ref quantity);
            HealthFragment       payload = new HealthFragment(null, HealthType.Damaging, quantity);
            ProjectileController projectileController = Service.ProjectileController;

            if (specialAttack.TargetShield != null && !specialAttack.VO.ProjectileType.PassThroughShield)
            {
                Entity shieldBorderEntity = specialAttack.TargetShield.ShieldBorderEntity;
                if (shieldBorderEntity == null)
                {
                    logger.Error("SpawnProjectile: shieldTarget is null");
                    this.SendSpecialAttackFired(specialAttack.VO);
                    return;
                }
                Vector3 targetWorldPos = specialAttack.TargetWorldPos;
                Vector3 targetWorldLoc = Vector3.zero;
                if (!Service.ShieldController.GetRayShieldIntersection(position, specialAttack.TargetWorldPos, specialAttack.TargetShield, out targetWorldLoc))
                {
                    targetWorldLoc = targetWorldPos;
                }
                Target target      = Target.CreateTargetWithWorldLocation((SmartEntity)shieldBorderEntity, targetWorldLoc);
                int    spawnBoardX = Units.WorldToBoardX((float)((int)position.x));
                int    spawnBoardZ = Units.WorldToBoardZ((float)((int)position.z));
                projectileController.SpawnProjectileForTarget(specialAttack.VO.HitDelay, spawnBoardX, spawnBoardZ, position, target, payload, specialAttack.TeamType, null, specialAttack.VO.ProjectileType, false, specialAttack.SpecialAttackBuffs, specialAttack.VO.Faction, null);
                this.AddProjectileInFlight(specialAttack.VO.ProjectileType);
            }
            else
            {
                Bullet bullet = projectileController.SpawnProjectileForTargetPosition(specialAttack.VO.HitDelay, position, specialAttack.TargetBoardX, specialAttack.TargetBoardZ, payload, specialAttack.TeamType, null, specialAttack.VO.ProjectileType, specialAttack.SpecialAttackBuffs, specialAttack.VO.Faction, specialAttack.VO.HasDropoff);
                if (specialAttack.VO.HasDropoff)
                {
                    bullet.Cookie = specialAttack;
                    ProjectileView projectileView = Service.ProjectileViewManager.SpawnProjectile(bullet);
                    Transform      transform      = projectileView.GetTransform();
                    this.AttachGameObject(transform, specialAttack.StarshipDetachableGameObject, false);
                    specialAttack.UpdateDetachableShadowAnimator(SpecialAttackDetachableObjectState.Falling);
                }
                this.AddProjectileInFlight(specialAttack.VO.ProjectileType);
            }
            this.SendSpecialAttackFired(specialAttack.VO);
        }