void Start()
    {
        inputManager = inputManager == null?FindObjectOfType <InputManager>() : inputManager;

        canvas.enabled = false;

        RectTransform containerTransform = (RectTransform)slotContainer.transform;
        RectTransform slotTransform      = (RectTransform)itemSlotPrefab.transform;

        double rawItemsPerRow = containerTransform.rect.width / slotTransform.rect.width;
        int    itemsPerRow    = (int)Math.Floor(rawItemsPerRow);

        double offsetLeftRelative = (rawItemsPerRow - itemsPerRow) / 2.0f;
        float  offsetLeft         = (float)(slotTransform.rect.width * offsetLeftRelative);

        Vector2 oldPivot = containerTransform.pivot;

        containerTransform.pivot = new Vector2(0, 1);

        float slotWidth  = slotTransform.rect.width;
        float slotHeight = slotTransform.rect.height;

        int index = 0;

        items.ForEach((item) => {
            GameObject slot = InitSlot(item);
            slot.transform.SetParent(slotContainer.transform);

            SlotInstance inst = new SlotInstance();
            inst.uiSlot       = slot;
            inst.item         = item;
            slotInstances.Add(inst);

            RectTransform rect = (RectTransform)slot.transform;
            rect.localPosition = Vector3.zero;
            rect.localScale    = Vector3.one;
            rect.pivot         = new Vector2(0, 1);

            int row            = index / itemsPerRow;
            int column         = index % itemsPerRow;
            rect.localPosition = new Vector2(offsetLeft + column * slotWidth, -slotHeight * row);

            index += 1;
        });

        // FIXME This is *totally* not the proper place to do this, but
        //       it gets the job done for the last sprint.
        GiveItem("weapon-fist");

        containerTransform.pivot = oldPivot;
        updateSlots();
    }
Ejemplo n.º 2
0
        /// <summary>
        /// 夜戦での威力を求めます。
        /// </summary>
        private int CalculateNightBattlePower()
        {
            var    kind      = Calculator.GetNightAttackKind(AllSlotMaster.ToArray(), ShipID, -1);
            double basepower = 0;

            if (kind == NightAttackKind.CutinAirAttack)
            {
                var airs = SlotInstance.Zip(Aircraft, (eq, count) => new { eq, master = eq?.MasterEquipment, count }).Where(a => a.eq != null);

                basepower = FirepowerBase +
                            airs.Where(p => p.master.IsNightAircraft)
                            .Sum(p => p.master.Firepower + p.master.Torpedo + p.master.Bomber +
                                 3 * p.count +
                                 0.45 * (p.master.Firepower + p.master.Torpedo + p.master.Bomber + p.master.ASW) * Math.Sqrt(p.count) + Math.Sqrt(p.eq.Level)) +
                            airs.Where(p => p.master.IsSwordfish || p.master.EquipmentID == 154 || p.master.EquipmentID == 320) // 零戦62型(爆戦/岩井隊)、彗星一二型(三一号光電管爆弾搭載機)
                            .Sum(p => p.master.Firepower + p.master.Torpedo + p.master.Bomber +
                                 0.3 * (p.master.Firepower + p.master.Torpedo + p.master.Bomber + p.master.ASW) * Math.Sqrt(p.count) + Math.Sqrt(p.eq.Level));
            }
            else if (ShipID == 515 || ShipID == 393)
            {       // Ark Royal (改)
                basepower = FirepowerBase + SlotInstanceMaster.Where(eq => eq?.IsSwordfish ?? false).Sum(eq => eq.Firepower + eq.Torpedo);
            }
            else if (ShipID == 353 || ShipID == 432 || ShipID == 433)
            {       // Graf Zeppelin(改), Saratoga
                basepower = FirepowerBase + SlotInstanceMaster.Where(eq => eq?.IsSwordfish ?? false).Sum(eq => eq.Firepower + eq.Torpedo);
            }
            else
            {
                basepower = FirepowerTotal + TorpedoTotal + GetNightBattleEquipmentLevelBonus();
            }


            basepower *= GetHPDamageBonus();

            switch (kind)
            {
            case NightAttackKind.DoubleShelling:
                basepower *= 1.2;
                break;

            case NightAttackKind.CutinMainTorpedo:
                basepower *= 1.3;
                break;

            case NightAttackKind.CutinTorpedoTorpedo:
            {
                switch (Calculator.GetNightTorpedoCutinKind(AllSlotInstanceMaster, ShipID, -1))
                {
                case NightTorpedoCutinKind.LateModelTorpedoSubmarineEquipment:
                    basepower *= 1.75;
                    break;

                case NightTorpedoCutinKind.LateModelTorpedo2:
                    basepower *= 1.6;
                    break;

                default:
                    basepower *= 1.5;
                    break;
                }
            }
            break;

            case NightAttackKind.CutinMainSub:
                basepower *= 1.75;
                break;

            case NightAttackKind.CutinMainMain:
                basepower *= 2.0;
                break;

            case NightAttackKind.CutinAirAttack:
            {
                int nightFighter  = SlotInstanceMaster.Count(eq => eq?.IsNightFighter ?? false);
                int nightAttacker = SlotInstanceMaster.Count(eq => eq?.IsNightAttacker ?? false);
                int nightBomber   = SlotInstanceMaster.Count(eq => eq?.EquipmentID == 320);           // 彗星一二型(三一号光電管爆弾搭載機)

                if (nightFighter >= 2 && nightAttacker >= 1)
                {
                    basepower *= 1.25;
                }
                else if (nightBomber >= 1 && nightFighter + nightAttacker >= 1)
                {
                    basepower *= 1.2;
                }
                else if (nightFighter >= 1 && nightAttacker >= 1)
                {
                    basepower *= 1.2;
                }
                else
                {
                    basepower *= 1.18;
                }
            }
            break;

            case NightAttackKind.CutinTorpedoRadar:
                if (ShipID == 543 && AllSlotInstanceMaster.Any(eq => eq?.EquipmentID == 267))         // 長波改二 + 12.7cm連装砲D型改二
                {
                    basepower *= 1.625;
                }
                else
                {
                    basepower *= 1.3;
                }
                break;

            case NightAttackKind.CutinTorpedoPicket:
                basepower *= 1.25;
                break;
            }

            basepower += GetLightCruiserDamageBonus() + GetItalianDamageBonus();

            //キャップ
            basepower = Math.Floor(CapDamage(basepower, 300));


            return((int)(basepower * GetAmmoDamageRate()));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 装備改修補正(対潜)
 /// </summary>
 private double GetAntiSubmarineEquipmentLevelBonus()
 {
     return(SlotInstance.Sum(s => s == null ? 0.0 : (s.MasterEquipment.CategoryType == 14 || s.MasterEquipment.CategoryType == 15) ? Math.Sqrt(s.Level) : 0.0));
 }