コード例 #1
0
 public Match(TurretComponent component, Vector3 position, Quaternion rotation, Dictionary <AttachmentSlot, AttachmentPoint> slotPointMappings)
 {
     Component         = component;
     Position          = position;
     Rotation          = rotation;
     SlotPointMappings = slotPointMappings;
 }
コード例 #2
0
        public void Update()
        {
            if (Input.SecondaryPerformed)
            {
                Vector3 mousePos   = MousePosition.WorldPosition;
                var     cols       = Physics2D.OverlapPointAll(mousePos);
                var     components = cols.Select(x => x.GetComponent <TurretComponent>()).Where(x => x != null);

                TurretComponent highest    = null;
                float           highestNum = float.MinValue;

                foreach (var component in components)
                {
                    float val = component.transform.position.z;
                    if (val > highestNum && component.AttachmentSlots.GetPointsOfType(Structures.Turrets.Attachment.AttachmentType.Upper).All(x => x.IsEmpty()))
                    {
                        highestNum = val;
                        highest    = component;
                    }
                }

                if (highest != null)
                {
                    Destroy(highest.gameObject);
                }
            }
        }
コード例 #3
0
 public bool Pickup(GameObject obj)
 {
     _obj        = obj;
     _model      = UnityUtils.InstantiateMockGO(_obj);
     _componenet = _obj.GetComponent <TurretComponent>();
     _obj.SetActive(false);
     return(_componenet != null);
 }
コード例 #4
0
ファイル: Battery.cs プロジェクト: MrLogic85/Assault-Defence
    private void Fitted(TurretComponent component, Armament arment)
    {
        Turret turret;

        if (component.GetTurret(out turret))
        {
            turret.RegisterBatery(this);
        }
    }
コード例 #5
0
 internal virtual void FittedOn(TurretComponent component, Armament armament)
 {
     parentComponent   = component;
     fittedOnArmamanet = armament;
     if (onFittedEvent != null)
     {
         onFittedEvent.Invoke(component, armament);
     }
 }
コード例 #6
0
    internal TurretComponent InstantiateComponentAt(TurretComponent comp, Slot slot)
    {
        TurretComponent instance = Instantiate(comp, slot.transform.position, slot.transform.rotation) as TurretComponent;

        instance.transform.parent = slot.transform;
        slot.component            = instance;
        instance.FittedOn(this, slot.armament);
        return(instance);
    }
コード例 #7
0
ファイル: Motor.cs プロジェクト: MrLogic85/Assault-Defence
    void Awake()
    {
        component = GetComponent <TurretComponent>();
        component.onComponenGetAimWeightEvent.Add(GetAimOffsetWeight);

        if (component.parentComponent != null)
        {
            Fitted(component.parentComponent, component.fittedOnArmamanet);
        }
        else
        {
            component.onFittedEvent += Fitted;
        }
    }
コード例 #8
0
        public TurretComponent Assemble(ObjectModel model, Transform parent, TurretAssembly assembly, AssemblyContext context)
        {
            IContentCachedPrefab component    = GetComponent(model.GetValue <string>("UniqueIdentifier"));
            ValueAssembler       assembler    = new ValueAssembler();
            GameObject           obj          = component.Instantiate();
            TurretComponent      newComponent = obj.GetComponent <TurretComponent>();

            if (parent != null)
            {
                obj.transform.SetParent(parent.transform);
                var position = (Vector2)assembler.Assemble(model.GetObject("LocalPosition"), typeof(Vector2), context);

                obj.transform.localPosition = (Vector3)position + Vector3.back * 0.1f;

                if (model.HasProperty("Angle"))
                {
                    obj.transform.localRotation = Quaternion.Euler(0f, 0f, model.GetValue <float>("Angle"));
                }
                if (model.HasProperty("Flipped"))
                {
                    if (model.GetValue <bool>("Flipped"))
                    {
                        newComponent.Flip();
                    }
                }

                TurretComponent parentComponent = parent.GetComponent <TurretComponent>();
                foreach (var point in newComponent.AttachmentPoints)
                {
                    AttachmentSlot slot = FindSlotForPoint(parentComponent.AttachmentSlots.GetSupportingPoints(point), point, obj.transform, parent.transform);
                    if (slot != null)
                    {
                        slot.Attach(newComponent);
                    }
                }
            }
            else
            {
                obj.transform.SetParent(assembly.transform);
                obj.transform.localPosition = Vector3.zero;
            }

            foreach (ValueModel child in model.GetArray("Children"))
            {
                Assemble(child as ObjectModel, newComponent.transform, assembly, context);
            }

            return(newComponent);
        }
コード例 #9
0
ファイル: Battery.cs プロジェクト: MrLogic85/Assault-Defence
    void Start()
    {
        component = GetComponent <TurretComponent>();
        Turret turret;

        if (component.GetTurret(out turret))
        {
            turret.RegisterBatery(this);
        }
        else
        {
            component.onFittedEvent += Fitted;
        }

        UpdateGlow();
    }
コード例 #10
0
 // ==== DEBUG ====
 internal override void BuildRandom()
 {
     foreach (Slot slot in slots)
     {
         TurretComponentLibrary library = FindObjectOfType <TurretComponentLibrary>();
         if (library != null)
         {
             TurretComponent[] components = library.GetComponentsMatching(slot, typeof(Motor));
             if (components.Length > 0)
             {
                 TurretComponent baseComponent = components[UnityEngine.Random.Range(0, components.Length)];
                 InstantiateComponentAt(baseComponent, slot);
                 slot.component.BuildRandom();
             }
         }
     }
 }
コード例 #11
0
    internal virtual void BuildRandom(int[] generateIds)
    {
        TurretComponentLibrary library = FindObjectOfType <TurretComponentLibrary>();

        if (library != null)
        {
            for (int i = 0; i < slots.Length && i < generateIds.Length; i++)
            {
                TurretComponent[] components = library.GetComponentsMatching(slots[i]);
                if (components.Length > 0 && generateIds[i] < components.Length && generateIds[i] >= 0)
                {
                    TurretComponent turretComponent = components[generateIds[i]];
                    InstantiateComponentAt(turretComponent, slots[i]);
                    slots[i].component.BuildRandom(Util.Subset(generateIds, slots.Length));
                }
            }
        }
    }
コード例 #12
0
        public ObjectModel Dissassemble(TurretComponent component, DisassemblyContext context)
        {
            GameObject         obj      = component.gameObject;
            List <ObjectModel> children = new List <ObjectModel>();

            foreach (Transform child in obj.transform)
            {
                TurretComponent childComponent = child.GetComponent <TurretComponent>();
                if (childComponent != null)
                {
                    children.Add(Dissassemble(childComponent, context));
                }
            }

            return(new ObjectModel(
                       new ObjectField("UniqueIdentifier", ValueModelFactory.Create(component.Identifier, context)),
                       new ObjectField("LocalPosition", ValueModelFactory.Create((Vector2)obj.transform.localPosition, context)),
                       new ObjectField("Angle", ValueModelFactory.Create(obj.transform.localRotation.eulerAngles.z, context)),
                       new ObjectField("Flipped", ValueModelFactory.Create(component.Flipped, context)),
                       new ObjectField("Children", new ArrayModel(children))
                       ));
        }
コード例 #13
0
    internal TurretComponent[] GetComponentsMatching(Slot slot, Type filter = null)
    {
        TurretComponent[] components = new TurretComponent[parts.Length + utilities.Length + weapons.Length];
        Array.Copy(parts, components, parts.Length);
        Array.Copy(utilities, 0, components, parts.Length, utilities.Length);
        Array.Copy(weapons, 0, components, parts.Length + utilities.Length, weapons.Length);

        ArrayList filteredComponents = new ArrayList();

        for (int i = 0; i < components.Length; i++)
        {
            TurretComponent component = components[i];
            Fitting         fitting   = component.fitting;
            if (!fitting.size.Fits(slot.size))
            {
                // Make sure the fitting is smaller or equal than the slot
                continue;
            }
            if (!fitting.armament.Fits(slot.armament))
            {
                // Make sure tha armament type can fit in the slot
                continue;
            }
            if (filter != null && component.GetComponent(filter) == null)
            {
                // Make sure the object is of the corect type
                continue;
            }
            // else
            filteredComponents.Add(component);
        }

        TurretComponent[] objects = new TurretComponent[filteredComponents.Count];
        Array.Copy(filteredComponents.ToArray(), objects, filteredComponents.Count);

        return(objects);
    }
コード例 #14
0
        public bool ToPosition(Vector2 position, Quaternion rotation)
        {
            _hoverPoint     = null;
            _hoverComponent = null;

            int size = (int)_root.GetSize();

            if (size == 1)
            {
                position = new Vector2(Mathf.Round(position.x - 0.5f) + 0.5f, Mathf.Round(position.y - 0.5f) + 0.5f);
            }
            else
            {
                position = new Vector2(
                    Mathf.Round(position.x / size) * size,
                    Mathf.Round(position.y / size) * size
                    );
            }

            transform.position = position;
            transform.rotation = rotation;

            return(CanPlace(transform.position, size / 2f));
        }
コード例 #15
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            AggregateFactory = new AggregateFactory(this);
            WeaponFactory = new WeaponFactory(this);
            DoorFactory = new DoorFactory(this);
            RoomFactory = new RoomFactory(this);
            CollectableFactory = new CollectibleFactory(this);
            WallFactory = new WallFactory(this);
            EnemyFactory = new EnemyFactory(this);
            SkillEntityFactory = new SkillEntityFactory(this);
            NPCFactory = new NPCFactory(this);

            // Initialize Components
            PlayerComponent = new PlayerComponent();
            LocalComponent = new LocalComponent();
            RemoteComponent = new RemoteComponent();
            PositionComponent = new PositionComponent();
            MovementComponent = new MovementComponent();
            MovementSpriteComponent = new MovementSpriteComponent();
            SpriteComponent = new SpriteComponent();
            DoorComponent = new DoorComponent();
            RoomComponent = new RoomComponent();
            HUDSpriteComponent = new HUDSpriteComponent();
            HUDComponent = new HUDComponent();
            InventoryComponent = new InventoryComponent();
            InventorySpriteComponent = new InventorySpriteComponent();
            ContinueNewGameScreen = new ContinueNewGameScreen(graphics, this);
            EquipmentComponent = new EquipmentComponent();
            WeaponComponent = new WeaponComponent();
            BulletComponent = new BulletComponent();
            PlayerInfoComponent = new PlayerInfoComponent();
            WeaponSpriteComponent = new WeaponSpriteComponent();
            StatsComponent = new StatsComponent();
            EnemyAIComponent = new EnemyAIComponent();
            NpcAIComponent = new NpcAIComponent();

            CollectibleComponent = new CollectibleComponent();
            CollisionComponent = new CollisionComponent();
            TriggerComponent = new TriggerComponent();
            EnemyComponent = new EnemyComponent();
            NPCComponent = new NPCComponent();
            //QuestComponent = new QuestComponent();
            LevelManager = new LevelManager(this);
            SpriteAnimationComponent = new SpriteAnimationComponent();
            SkillProjectileComponent = new SkillProjectileComponent();
            SkillAoEComponent = new SkillAoEComponent();
            SkillDeployableComponent = new SkillDeployableComponent();
            SoundComponent = new SoundComponent();
            ActorTextComponent = new ActorTextComponent();
            TurretComponent = new TurretComponent();
            TrapComponent = new TrapComponent();
            ExplodingDroidComponent = new ExplodingDroidComponent();
            HealingStationComponent = new HealingStationComponent();
            PortableShieldComponent = new PortableShieldComponent();
            PortableStoreComponent = new PortableStoreComponent();
            ActiveSkillComponent = new ActiveSkillComponent();
            PlayerSkillInfoComponent = new PlayerSkillInfoComponent();

            Quests = new List<Quest>();

            #region Initialize Effect Components
            AgroDropComponent = new AgroDropComponent();
            AgroGainComponent = new AgroGainComponent();
            BuffComponent = new BuffComponent();
            ChanceToSucceedComponent = new ChanceToSucceedComponent();
            ChangeVisibilityComponent = new ChangeVisibilityComponent();
            CoolDownComponent = new CoolDownComponent();
            DamageOverTimeComponent = new DamageOverTimeComponent();
            DirectDamageComponent = new DirectDamageComponent();
            DirectHealComponent = new DirectHealComponent();
            FearComponent = new FearComponent();
            HealOverTimeComponent = new HealOverTimeComponent();
            InstantEffectComponent = new InstantEffectComponent();
            KnockBackComponent = new KnockBackComponent();
            TargetedKnockBackComponent = new TargetedKnockBackComponent();
            ReduceAgroRangeComponent = new ReduceAgroRangeComponent();
            ResurrectComponent = new ResurrectComponent();
            StunComponent = new StunComponent();
            TimedEffectComponent = new TimedEffectComponent();
            EnslaveComponent = new EnslaveComponent();
            CloakComponent = new CloakComponent();
            #endregion

            base.Initialize();
        }
コード例 #16
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            AggregateFactory   = new AggregateFactory(this);
            WeaponFactory      = new WeaponFactory(this);
            DoorFactory        = new DoorFactory(this);
            RoomFactory        = new RoomFactory(this);
            CollectableFactory = new CollectibleFactory(this);
            WallFactory        = new WallFactory(this);
            EnemyFactory       = new EnemyFactory(this);
            SkillEntityFactory = new SkillEntityFactory(this);
            NPCFactory         = new NPCFactory(this);

            // Initialize Components
            PlayerComponent          = new PlayerComponent();
            LocalComponent           = new LocalComponent();
            RemoteComponent          = new RemoteComponent();
            PositionComponent        = new PositionComponent();
            MovementComponent        = new MovementComponent();
            MovementSpriteComponent  = new MovementSpriteComponent();
            SpriteComponent          = new SpriteComponent();
            DoorComponent            = new DoorComponent();
            RoomComponent            = new RoomComponent();
            HUDSpriteComponent       = new HUDSpriteComponent();
            HUDComponent             = new HUDComponent();
            InventoryComponent       = new InventoryComponent();
            InventorySpriteComponent = new InventorySpriteComponent();
            ContinueNewGameScreen    = new ContinueNewGameScreen(graphics, this);
            EquipmentComponent       = new EquipmentComponent();
            WeaponComponent          = new WeaponComponent();
            BulletComponent          = new BulletComponent();
            PlayerInfoComponent      = new PlayerInfoComponent();
            WeaponSpriteComponent    = new WeaponSpriteComponent();
            StatsComponent           = new StatsComponent();
            EnemyAIComponent         = new EnemyAIComponent();
            NpcAIComponent           = new NpcAIComponent();

            CollectibleComponent = new CollectibleComponent();
            CollisionComponent   = new CollisionComponent();
            TriggerComponent     = new TriggerComponent();
            EnemyComponent       = new EnemyComponent();
            NPCComponent         = new NPCComponent();
            //QuestComponent = new QuestComponent();
            LevelManager             = new LevelManager(this);
            SpriteAnimationComponent = new SpriteAnimationComponent();
            SkillProjectileComponent = new SkillProjectileComponent();
            SkillAoEComponent        = new SkillAoEComponent();
            SkillDeployableComponent = new SkillDeployableComponent();
            SoundComponent           = new SoundComponent();
            ActorTextComponent       = new ActorTextComponent();
            TurretComponent          = new TurretComponent();
            TrapComponent            = new TrapComponent();
            ExplodingDroidComponent  = new ExplodingDroidComponent();
            HealingStationComponent  = new HealingStationComponent();
            PortableShieldComponent  = new PortableShieldComponent();
            PortableStoreComponent   = new PortableStoreComponent();
            ActiveSkillComponent     = new ActiveSkillComponent();
            PlayerSkillInfoComponent = new PlayerSkillInfoComponent();
            MatchingPuzzleComponent  = new MatchingPuzzleComponent();
            pI = new PlayerInfo();

            Quests = new List <Quest>();


            #region Initialize Effect Components
            AgroDropComponent          = new AgroDropComponent();
            AgroGainComponent          = new AgroGainComponent();
            BuffComponent              = new BuffComponent();
            ChanceToSucceedComponent   = new ChanceToSucceedComponent();
            ChangeVisibilityComponent  = new ChangeVisibilityComponent();
            CoolDownComponent          = new CoolDownComponent();
            DamageOverTimeComponent    = new DamageOverTimeComponent();
            DirectDamageComponent      = new DirectDamageComponent();
            DirectHealComponent        = new DirectHealComponent();
            FearComponent              = new FearComponent();
            HealOverTimeComponent      = new HealOverTimeComponent();
            PsiOrFatigueRegenComponent = new PsiOrFatigueRegenComponent();
            InstantEffectComponent     = new InstantEffectComponent();
            KnockBackComponent         = new KnockBackComponent();
            TargetedKnockBackComponent = new TargetedKnockBackComponent();
            ReduceAgroRangeComponent   = new ReduceAgroRangeComponent();
            ResurrectComponent         = new ResurrectComponent();
            StunComponent              = new StunComponent();
            TimedEffectComponent       = new TimedEffectComponent();
            EnslaveComponent           = new EnslaveComponent();
            CloakComponent             = new CloakComponent();
            #endregion

            base.Initialize();
        }
コード例 #17
0
ファイル: Turret.cs プロジェクト: MrLogic85/Assault-Defence
 // Use this for initialization
 void Start()
 {
     turretComponent = GetComponent <TurretComponent>();
 }
コード例 #18
0
ファイル: Motor.cs プロジェクト: MrLogic85/Assault-Defence
 // A motor has the same armament as the slot it was fitted on.
 private void Fitted(TurretComponent parentComponent, Armament armament)
 {
     component.slots[0].armament = armament;
 }