コード例 #1
0
        protected override void InitializeLogic()
        {
            var logicSet = new LogicSet(this);

            logicSet.AddAction(new ChangePropertyLogicAction(this, "Shake", true));
            logicSet.AddAction(new DelayLogicAction(1f));
            logicSet.AddAction(new ChangePropertyLogicAction(this, "Shake", false));
            logicSet.AddAction(new DelayLogicAction(1f));
            var logicSet2 = new LogicSet(this);

            logicSet2.AddAction(new ChaseLogicAction(m_target, Vector2.Zero, Vector2.Zero, true, 1f));
            var logicSet3 = new LogicSet(this);

            logicSet3.AddAction(new ChaseLogicAction(m_target, Vector2.Zero, Vector2.Zero, true, 1.75f));
            ThrowAdvancedProjectiles(logicSet3, true);
            var logicSet4 = new LogicSet(this);

            logicSet4.AddAction(new ChaseLogicAction(m_target, Vector2.Zero, Vector2.Zero, true, 1.75f));
            ThrowExpertProjectiles(logicSet4, true);
            var logicSet5 = new LogicSet(this);

            logicSet5.AddAction(new ChaseLogicAction(m_target, Vector2.Zero, Vector2.Zero, true, 1.25f));
            ThrowProjectiles(logicSet5, true);
            m_generalBasicLB.AddLogicSet(logicSet, logicSet2);
            m_generalAdvancedLB.AddLogicSet(logicSet, logicSet3);
            m_generalExpertLB.AddLogicSet(logicSet, logicSet4);
            m_generalMiniBossLB.AddLogicSet(logicSet, logicSet5);
            m_generalCooldownLB.AddLogicSet(logicSet, logicSet2);
            logicBlocksToDispose.Add(m_generalBasicLB);
            logicBlocksToDispose.Add(m_generalAdvancedLB);
            logicBlocksToDispose.Add(m_generalExpertLB);
            logicBlocksToDispose.Add(m_generalMiniBossLB);
            logicBlocksToDispose.Add(m_generalCooldownLB);
            base.InitializeLogic();
            CollisionBoxes.Clear();
            CollisionBoxes.Add(new CollisionBox((int)(-18f * ScaleX), (int)(-24f * ScaleY), (int)(36f * ScaleX),
                                                (int)(48f * ScaleY), 2, this));
            CollisionBoxes.Add(new CollisionBox((int)(-15f * ScaleX), (int)(-21f * ScaleY), (int)(31f * ScaleX),
                                                (int)(44f * ScaleY), 1, this));
            if (Difficulty == GameTypes.EnemyDifficulty.MINIBOSS)
            {
                (GetChildAt(0) as SpriteObj).ChangeSprite("GiantPortrait_Sprite");
                Scale = new Vector2(2f, 2f);
                AddChild(new SpriteObj("Portrait" + CDGMath.RandomInt(0, 7) + "_Sprite")
                {
                    OverrideParentScale = true
                });
                CollisionBoxes.Clear();
                CollisionBoxes.Add(new CollisionBox(-124, -176, 250, 354, 2, this));
                CollisionBoxes.Add(new CollisionBox(-124, -176, 250, 354, 1, this));
            }
        }
コード例 #2
0
 public void SetHitboxTypes(IEnumerable <string> hitboxTypes)
 {
     CollisionBoxes.Clear();
     CollisionBoxes.AddRange(hitboxTypes);
 }
コード例 #3
0
        // Create multiple collision boxes from BossStructure
        private void ComputeCollisionBoxes()
        {
            CollisionBoxes.Clear();
            _collisionBoxesHp.Clear();

            // TODO: Handle the case where there is 2 vertices with Y = 0
            var vertices       = _structure.GetVertices();
            var bottomVertices = new List <Vector2>(); // the lowest vertex for each step
            var topVertices    = new List <Vector2>(); // the highest vertex for each step
            var currentStep    = 0f;

            for (var i = 0; i < vertices.Length; i++)
            {
                // Bottom part
                if (vertices[i].Y >= 0)
                {
                    if (vertices[i].X > currentStep)
                    {
                        bottomVertices.Add(vertices[i - 1]);
                        bottomVertices.Add(vertices[i]);
                    }
                }
                // Top part
                else
                {
                    if (vertices[i].X < currentStep)
                    {
                        topVertices.Add(vertices[i - 1]);
                        topVertices.Add(vertices[i]);
                    }
                }

                currentStep = vertices[i].X;
            }

            if (bottomVertices.Count != topVertices.Count)
            {
                // Left part
                if (bottomVertices.First().Y.Equals(0f))
                {
                    topVertices.Add(vertices[vertices.Length - 1]);
                    topVertices.Add(bottomVertices.First());
                    topVertices.Reverse();
                }
                // Right part
                else if (bottomVertices.Last().Y.Equals(0f))
                {
                    topVertices.Reverse();
                    topVertices.Add(bottomVertices.Last());
                }
            }
            else
            {
                topVertices.Reverse();
            }

            if (bottomVertices.Count != topVertices.Count)
            {
                return;
            }

            for (var i = 1; i < bottomVertices.Count; i += 2)
            {
                var boxVertices = new List <Vector2>
                {
                    bottomVertices[i],
                    bottomVertices[i - 1],
                    topVertices[i - 1],
                    topVertices[i]
                };

                var collisionBox = new CollisionConvexPolygon(this, Vector2.Zero, boxVertices);
                CollisionBoxes.Add(collisionBox);
                _collisionBoxesHp.Add(collisionBox, 100f);
            }
        }