Ejemplo n.º 1
0
    public void SetData(Sail s, SailShopSceneController sssc)
    {
        LocalizationManager lz = MainGameController.instance.localizationManager;

        _sailNameText.text  = s.Name;
        _sailStatsText.text = lz.GetLocalizedValue("max_wind_speed_text") + ": \t\t\t\t" + s.MaxWindSpeed + "\n" +
                              lz.GetLocalizedValue("speed_text") + ": \t\t\t" + s.SpeedModifier + "\n" +
                              lz.GetLocalizedValue("damage_text") + ": \t\t\t" + s.DamageModifier + "\n" +
                              lz.GetLocalizedValue("offline_speed_text") + ": \t" + s.OfflineSpeedModifier;
        if (!s.Bought)
        {
            _sailBuyText.text = lz.GetLocalizedValue("buy_text") + "\n" + s.Price + " " + lz.GetLocalizedValue("gold_text")[0];
            _sailBuyButton.onClick.RemoveAllListeners();
            _sailBuyButton.onClick.AddListener(delegate { sssc.BuySail(s); });
        }
        else if (!s.Active)
        {
            _sailBuyText.text = lz.GetLocalizedValue("use_text");
            _sailBuyButton.onClick.RemoveAllListeners();
            _sailBuyButton.onClick.AddListener(delegate { sssc.UseSail(s); });
            _sailBuyButton.enabled = true;
        }
        else
        {
            _sailBuyText.text      = lz.GetLocalizedValue("using_text");
            _sailBuyButton.enabled = false;
        }
    }
Ejemplo n.º 2
0
        public InputEquationForm(List<object> AutoFillVariables, string currentText, Sail s)
        {
            InitializeComponent();

            m_sail = s;

            CalculateButton.Enabled = m_sail != null;
            // TODO: Complete member initialization

            autoCompleteTextBox1.Text = currentText;

            if (AutoFillVariables != null)
            {
                autoCompleteTextBox1.Values = AutoFillVariables.ToArray();

                AutoFillVariables.ForEach(var =>
                {
                    if (var is MouldCurve)
                        CurveListBox.Items.Add(var);
                    else if (var is Equation)
                        EquationListBox.Items.Add((var as Equation).Label);
                    //else if (var is Equation)
                    //	EquationListBox.Items.Add((var as Equation).Label);
                });
            }
        }
Ejemplo n.º 3
0
    public static void RotateSailsTo(Sail sail)
    {
        if (network == null)
        {
            network = ComponentManager <Semih_Network> .Value;
        }
        List <Sail> allSails = Sail.AllSails;

        foreach (Sail current in allSails)
        {
            if (sail != current)
            {
                float axis = (sail.LocalRotation - current.LocalRotation);
                if (Semih_Network.IsHost)
                {
                    AccessTools.Method("Sail:Rotate").Invoke(current, new object[] { axis });
                }
                else
                {
                    Message message = new Message_Sail_Rotate(Messages.Sail_Rotate, current, axis);
                    network.SendP2P(network.HostID, message, EP2PSend.k_EP2PSendReliable, NetworkChannel.Channel_Game);
                }
            }
        }
    }
Ejemplo n.º 4
0
        private void ShortDistanceNavigate(PlayerMove_Sail __instance)
        {
            VectorLF3 dir = target.GetDirection(__instance.player);

            Sail.SetDir(__instance, dir);

            VectorLF3 advisePoint = VectorLF3.zero;

            if (AdvisePointIfOcclusion(__instance, ref advisePoint, shortNavUncoverRange))
            {
#if DEBUG
                ModDebug.Log("Planet Navigate ToAdvisePoint:" + advisePoint);
#endif
                dir = (advisePoint - __instance.player.uPosition).normalized;
                Sail.SetDir(__instance, dir);
                Sail.TrySpeedUp(this, __instance);
            }
            else
            {
                if (Target.IsFocusingNormalized(dir, __instance.player.uVelocity.normalized))
                {
#if DEBUG
                    ModDebug.Log("Short Navigate - Speed Up");
#endif
                    Sail.TrySpeedUp(this, __instance);
                }
                else
                {
#if DEBUG
                    ModDebug.Log("Short Navigate - No Speed Up");
#endif
                }
            }
        }
Ejemplo n.º 5
0
 public void BuyBoat(Boat b)
 {
     if (MainGameController.instance.player.Gold >= b.Price)
     {
         Boat previousBoat = MainGameController.instance.databaseController.connection.Table <Boat>().Where(x => x.Active).FirstOrDefault();
         if (previousBoat != null)
         {
             previousBoat.Active = false;
             previousBoat.Save();
             Sail activeSail = previousBoat.GetSailsBought().Where(x => x.Active).First();
             if (!b.GetSailsBought().Contains(activeSail))
             {
                 activeSail.Active = false;
                 activeSail.Save();
                 Sail s = b.GetSailsBought().Where(x => x.Bought).First();
                 s.Active = true;
                 s.Save();
             }
         }
         MainGameController.instance.achievementManager.AddAchievementProperty(AchievementProperties.BoatsBought, 1);
         b.Bought = true;
         b.Active = true;
         b.Save();
         UpdateBoatBuyPanels();
         MainGameController.instance.player.GiveGold(-b.Price);
         MainGameController.instance.player.Save();
         _goldText.text = "Gold: " + MainGameController.instance.player.Gold;
     }
     else
     {
         Debug.LogError("Not enough gold to buy boat!");
     }
 }
Ejemplo n.º 6
0
    public SailBuyPanel CreateSailBuyPanel(Sail b)
    {
        GameObject   sbpGO = GameObject.Instantiate(_sailBuyPanel);
        SailBuyPanel sbp   = sbpGO.GetComponent <SailBuyPanel>();

        sbp.SetData(b, this);
        sbpGO.transform.SetParent(_sailBuyScrollViewContent.transform);
        sbpGO.transform.localScale = Vector3.one;
        return(sbp);
    }
Ejemplo n.º 7
0
    public override void Copy(Model m)
    {
        Sail s = (Sail)m;

        this.Name                 = s.Name;
        this.Price                = s.Price;
        this.MaxWindSpeed         = s.MaxWindSpeed;
        this.DamageModifier       = s.DamageModifier;
        this.SpeedModifier        = s.SpeedModifier;
        this.OfflineSpeedModifier = s.OfflineSpeedModifier;
    }
Ejemplo n.º 8
0
    public static void CompleteRequest(Request r)
    {
        r.Completed = true;

        object o          = r.GetReward();
        string rewardType = MainGameController.instance.localizationManager.GetLocalizedValue(r.RewardType);
        string athing     = MainGameController.instance.localizationManager.GetLocalizedValue("a_text");

        switch (o.GetType().Name)
        {
        case "Int32":
            int reward = (int)o;
            MainGameController.instance.player.GiveGold(reward);
            break;

        case "Boat":
            Boat b = (Boat)o;
            b.Bought = true;
            b.Save();
            rewardType = athing + " " + rewardType;
            break;

        case "Sail":
            Sail s = (Sail)o;
            s.Bought = true;
            s.Save();
            rewardType = athing + " " + rewardType;
            break;

        case "Upgrade":
            Upgrade u = (Upgrade)o;
            u.Bought = true;
            u.Save();
            rewardType = athing + " " + rewardType;
            break;

        case "Item":
            Item i = (Item)o;
            i.InInventory++;
            i.Save();
            rewardType = athing + " " + rewardType;
            break;

        default:
            Debug.LogWarning("Unknown reward type: " + o.GetType().Name);
            break;
        }

        r.Save();
        string popupText = string.Format(MainGameController.instance.localizationManager.GetLocalizedValue("completed_request_text"), rewardType);

        MainGameController.instance.popupManager.ViewPopup(popupText, null, 10);
    }
Ejemplo n.º 9
0
    public void SetData(Sail s)
    {
        LocalizationManager lz = MainGameController.instance.localizationManager;

        _sailNameText.text  = s.Name;
        _sailStatsText.text = lz.GetLocalizedValue("max_wind_speed_text") + ": " + s.MaxWindSpeed;// + "\nSpeed: \t\t\t" + s.SpeedModifier + "\nDamage: \t\t\t" + s.DamageModifier + "\nOffline Speed: \t" + s.OfflineSpeedModifier;
        _sailEquipText.text = lz.GetLocalizedValue("equip_text");
        if (s.Active)
        {
            _sailEquipText.text = lz.GetLocalizedValue("active_text");
        }
    }
Ejemplo n.º 10
0
 public float GetMaxWindSpeedSails()
 {
     if (GetSailsBought().Where(x => x.Active).Count() > 0)
     {
         Sail s = GetSailsBought().Where(x => x.Active).First();
         return(s.MaxWindSpeed);
     }
     else
     {
         return(GetSpeedModified());
     }
 }
Ejemplo n.º 11
0
    public float GetHullLenght()
    {
        float hullLengthModifier = 1;

        foreach (Upgrade u in GetUpgrades())
        {
            hullLengthModifier *= u.SpeedModifier;
        }
        Sail s = GetSailsBought().Where(x => x.Active).First();

        hullLengthModifier *= s.SpeedModifier;
        return(HullLength * hullLengthModifier);
    }
Ejemplo n.º 12
0
 public List <Sail> GetSailsBought()
 {
     _sails = new List <Sail>();
     foreach (int i in GetSailsId())
     {
         Sail s = MainGameController.instance.databaseController.connection.Table <Sail>().Where(x => x.id == i).First();
         if (s.Bought)
         {
             _sails.Add(s);
         }
     }
     return(_sails);
 }
Ejemplo n.º 13
0
    public void UseSail(Sail s)
    {
        TableQuery <Sail> activeSails = MainGameController.instance.databaseController.connection.Table <Sail>().Where(x => x.Active == true);

        if (activeSails.Count() > 0)
        {
            Sail curActive = activeSails.First();
            curActive.Active = false;
            curActive.Save();
        }
        s.Active = true;
        s.Save();
        UpdateSailBuyPanels();
    }
Ejemplo n.º 14
0
        public void PlanetNavigation(PlayerMove_Sail __instance)
        {
            ModDebug.Assert(IsCurNavPlanet());
            player = __instance.player;

            if (IsCurNavPlanet())
            {
                double distance = (target.TargetPlanet.uPosition - __instance.player.uPosition).magnitude;

                if ((enableLocalWrap &&
                     distance > localWrapMinDistance &&
                     distance > (target.TargetPlanet.realRadius + longNavUncoverRange))
                    ||
                    target.IsLocalStarPlanet() == false)
                {
                    PlanetData localPlanet = GameMain.localPlanet;
                    if (localPlanet != null &&
                        target.TargetPlanet != null &&
                        localPlanet.id != target.TargetPlanet.id)
                    {
#if DEBUG
                        ModDebug.Log("Leave Local Planet");
#endif
                        VectorLF3 dir = (__instance.player.uPosition - localPlanet.uPosition).normalized;
                        Sail.SetDir(__instance, dir);
                    }
                    else
                    {
#if DEBUG
                        ModDebug.Log("Local Long Distance Navigation");
#endif
                        LongDistanceNavigate(__instance);
                    }
                }
                else
                {
#if DEBUG
                    ModDebug.Log("Local Short Distance Navigation");
#endif
                    ShortDistanceNavigate(__instance);
                }
            }
            else
            {
                Arrive();
#if DEBUG
                ModDebug.Error("PlanetNavigation - No Target");
#endif
            }
        }
Ejemplo n.º 15
0
    public Ship(GameObject _go,Material _mat)
    {
        m_go=_go;

        Sail _sail=new Sail(_mat,new Vector2(1.0f,0.7f));
        _sail.get_go().transform.parent=m_go.transform;
        _sail.get_go().transform.localPosition=new Vector3(-0.5f,2.04f,0.7f);
        _sail.get_go().transform.localRotation=Quaternion.identity;
        m_sail_list.Add(_sail);

        //		_sail=new Sail(_mat,new Vector2(1.0f,0.8f));
        //		_sail.get_go().transform.parent=m_go.transform;
        //		_sail.get_go().transform.localPosition=new Vector3(-0.5f,1.7f,0.7f);
        //		_sail.get_go().transform.localRotation=Quaternion.identity;
        //		m_sail_list.Add(_sail);
    }
Ejemplo n.º 16
0
    public void ChangeSail(Sail sail)
    {
        Sail s = MainGameController.instance.player.GetActiveBoat().GetSailsBought().Where(x => x.Active).First();

        s.Active = false;
        s.Save();
        sail.Active = true;
        sail.Save();

        List <Sail> sails = MainGameController.instance.player.GetActiveBoat().GetSailsBought().ToList();

        for (int i = 0; i < sails.Count; i++)
        {
            _sailChangePanels[i].GetComponent <SailChangePanel>().SetData(sails[i]);
        }
    }
Ejemplo n.º 17
0
    public static void SailsRotate(float axis, Sail __instance)
    {
        Semih_Network value    = ComponentManager <Semih_Network> .Value;
        List <Sail>   allSails = Sail.AllSails;

        Type[] array = new Type[]
        {
            typeof(float)
        };
        object[] parameters = new object[]
        {
            axis
        };

        if (Semih_Network.IsHost)
        {
            AccessTools.Method("Sail:Rotate", array, null).Invoke(__instance, parameters);
        }
        else
        {
            Message message = new Message_Sail_Rotate(Messages.Sail_Rotate, __instance, axis);
            value.SendP2P(value.HostID, message, Steamworks.EP2PSend.k_EP2PSendReliable, NetworkChannel.Channel_Game);
        }

        foreach (Sail sail in allSails)
        {
            if (__instance != sail)
            {
                float    _axis       = (__instance.LocalRotation - sail.LocalRotation);
                object[] _parameters = new object[]
                {
                    _axis
                };

                if (Semih_Network.IsHost)
                {
                    AccessTools.Method("Sail:Rotate", array, null).Invoke(sail, _parameters);
                }
                else
                {
                    Message message = new Message_Sail_Rotate(Messages.Sail_Rotate, sail, _axis);
                    value.SendP2P(value.HostID, message, Steamworks.EP2PSend.k_EP2PSendReliable, NetworkChannel.Channel_Game);
                }
            }
        }
    }
Ejemplo n.º 18
0
        public void StarNavigation(PlayerMove_Sail __instance)
        {
            ModDebug.Assert(IsCurNavStar());
            player = __instance.player;

            if (IsCurNavStar())
            {
                PlanetData localPlanet = GameMain.localPlanet;
                if (localPlanet != null)
                {
#if DEBUG
                    ModDebug.Log("Leave Local Planet");
#endif
                    VectorLF3 dir = (__instance.player.uPosition - localPlanet.uPosition).normalized;
                    Sail.SetDir(__instance, dir);
                    return;
                }
                else
                {
                    if (DetermineArrive() && IsCloseToNearStar(__instance))
                    {
#if DEBUG
                        ModDebug.Log("StarNavigation Arrive");
#endif
                        Arrive();
                        Warp.TryLeaveWarp(__instance);
                        return;
                    }
                    else
                    {
                        LongDistanceNavigate(__instance);
                        return;
                    }
                }
            }
            else
            {
                Arrive();
#if DEBUG
                ModDebug.Error("StarNavigation - No Target");
#endif
            }
        }
Ejemplo n.º 19
0
        public void PlanetNavigation(PlayerMove_Sail __instance)
        {
            ModDebug.Assert(IsCurNavPlanet);
            player = __instance.player;

            if (!IsCurNavPlanet)
            {
                Arrive();
#if DEBUG
                ModDebug.Error("Planet navigation - Error target");
#endif
                return;
            }

            if (NeedLocalLongDistanceNavigate(__instance))
            {
                PlanetData localPlanet = GameMain.localPlanet;
                if (localPlanet != null &&
                    target.TargetPlanet != null &&
                    localPlanet.id != target.TargetPlanet.id)
                {
#if DEBUG
                    ModDebug.Log("Leave Local Planet");
#endif
                    VectorLF3 dir = (__instance.player.uPosition - localPlanet.uPosition).normalized;
                    Sail.SetDir(__instance, dir);
                }
                else
                {
#if DEBUG
                    ModDebug.Log("Local Long Distance Navigation");
#endif
                    LongDistanceNavigate(__instance);
                }

                return;
            }

#if DEBUG
            ModDebug.Log("Local Short Distance Navigation");
#endif
            ShortDistanceNavigate(__instance);
        }
Ejemplo n.º 20
0
    static bool Prefix(Sail __instance, ref CanvasHelper ___canvas, ref Network_Player ___localPlayer)
    {
        if (!MyInput.GetButton("Sprint"))
        {
            return(true);
        }
        if (Helper.LocalPlayerIsWithinDistance(__instance.transform.position, Player.UseDistance) && CanvasHelper.ActiveMenu == MenuType.None)
        {
            if (MyInput.GetButtonDown("Interact"))
            {
                if (Semih_Network.IsHost)
                {
                    if (__instance.open)
                    {
                        MoreSailsMoreSpeedMod.SailsClose();
                    }
                    else
                    {
                        MoreSailsMoreSpeedMod.SailsOpen();
                    }
                }
            }

            if (MyInput.GetButton("Rotate"))
            {
                if (___localPlayer.PlayerScript.MouseLookIsActive())
                {
                    ___localPlayer.PlayerScript.SetMouseLookScripts(false);
                }
                MoreSailsMoreSpeedMod.SailsRotate(Input.GetAxis("Mouse X"), __instance);
            }
            else if (MyInput.GetButtonUp("Rotate"))
            {
                ___localPlayer.PlayerScript.SetMouseLookScripts(true);
            }
            return(false);
        }
        else
        {
            ___canvas.displayTextManager.HideDisplayTexts();
        }
        return(false);
    }
Ejemplo n.º 21
0
    public static void SailsOpen()
    {
        Semih_Network value    = ComponentManager <Semih_Network> .Value;
        List <Sail>   allSails = Sail.AllSails;

        for (int i = 0; i < allSails.Count; i++)
        {
            Sail sail = allSails[i];
            Message_NetworkBehaviour message_NetworkBehaviour = new Message_NetworkBehaviour((!sail.open) ? Messages.Sail_Open : Messages.Sail_Close, sail);
            if (Semih_Network.IsHost)
            {
                sail.Open();
                value.RPC(message_NetworkBehaviour, Target.All, Steamworks.EP2PSend.k_EP2PSendReliableWithBuffering, 0);
            }
            else
            {
                value.SendP2P(value.HostID, message_NetworkBehaviour, Steamworks.EP2PSend.k_EP2PSendReliableWithBuffering, 0);
            }
        }
    }
Ejemplo n.º 22
0
    public static void SailsClose()
    {
        if (network == null)
        {
            network = ComponentManager <Semih_Network> .Value;
        }
        List <Sail> allSails = Sail.AllSails;

        for (int i = 0; i < allSails.Count; i++)
        {
            Sail sail = allSails[i];
            Message_NetworkBehaviour message = new Message_NetworkBehaviour(Messages.Sail_Close, sail);
            if (Semih_Network.IsHost)
            {
                AccessTools.Method("Sail:Close", null, null).Invoke(sail, null);
                network.RPC(message, Target.Other, EP2PSend.k_EP2PSendReliable, NetworkChannel.Channel_Game);
                continue;
            }
            network.SendP2P(network.HostID, message, EP2PSend.k_EP2PSendReliable, NetworkChannel.Channel_Game);
        }
    }
Ejemplo n.º 23
0
    public static void SailsClose()
    {
        Semih_Network value    = ComponentManager <Semih_Network> .Value;
        List <Sail>   allSails = Sail.AllSails;

        object[] parameters = new object[0];
        for (int i = 0; i < allSails.Count; i++)
        {
            Sail sail = allSails[i];
            Message_NetworkBehaviour message_NetworkBehaviour = new Message_NetworkBehaviour((!sail.open) ? Messages.Sail_Open : Messages.Sail_Close, sail);
            if (Semih_Network.IsHost)
            {
                AccessTools.Method("Sail:Close", null, null).Invoke(sail, parameters);
                value.RPC(message_NetworkBehaviour, Target.All, Steamworks.EP2PSend.k_EP2PSendReliableWithBuffering, 0);
            }
            else
            {
                value.SendP2P(value.HostID, message_NetworkBehaviour, Steamworks.EP2PSend.k_EP2PSendReliableWithBuffering, 0);
            }
        }
    }
Ejemplo n.º 24
0
    private void Awake()
    {
        if (!Application.isEditor)
        {
            startCrashed = !hasPlayedTutorial;
        }
        // Initialize sub components
        steering      = GetComponentInChildren <BoatSteering>();
        damageManager = GetComponentInChildren <BoatDamageManager>();
        lantern       = GetComponentInChildren <Lantern>();
        sail          = GetComponentInChildren <Sail>();
        captain       = GetComponentInChildren <Captain>();
        //Find main camera and attach camera controller script
        var camera = GameObject.FindGameObjectWithTag("MainCamera");

        cameraController            = camera.AddComponent <CameraController>();
        cameraController.cameraLead = cameraLead;
        // Position camera a little behind boat initially
        cameraController.transform.position = new Vector3(transform.position.x - 5f, transform.position.y - 5f, cameraController.transform.position.z);

        damageManager.boat = captain.boat = sail.boat = steering.boat = cameraController.boat = this;
    }
 static bool Prefix(Raft __instance, ref Rigidbody ___body, ref float ___speed, ref StudioEventEmitter ___eventEmitter_idle, ref Vector3 ___previousPosition)
 {
     if (!Semih_Network.IsHost)
     {
         return(false);
     }
     if (!__instance.IsAnchored && ___speed != 0f)
     {
         __instance.moveDirection = Vector3.forward;
         List <Sail> allSails = Sail.AllSails;
         Vector3     vector   = Vector3.zero;
         int         i        = 0;
         int         num      = 1;
         while (i < allSails.Count)
         {
             Sail sail = allSails[i];
             if (sail.open)
             {
                 vector += sail.GetNormalizedDirection() * (float)(num / Math.Pow(num, rate));
             }
             i++;
             num++;
         }
         if (vector.z < 0f)
         {
             vector.z = ((Mathf.Abs(vector.x) <= 0.7) ? -0.8f : (__instance.moveDirection.z = 0f));
         }
         __instance.moveDirection += vector;
         ___body.AddForce(__instance.moveDirection * ___speed);
     }
     if (___body.velocity.sqrMagnitude > __instance.maxVelocity)
     {
         ___body.velocity = Vector3.ClampMagnitude(___body.velocity, __instance.maxVelocity);
     }
     ___eventEmitter_idle.SetParameter("velocity", ___body.velocity.sqrMagnitude / __instance.maxVelocity);
     ___previousPosition = ___body.transform.position;
     return(false);
 }
Ejemplo n.º 26
0
    public void UseBoat(Boat b)
    {
        TableQuery <Boat> activeBoats = MainGameController.instance.databaseController.connection.Table <Boat>().Where(x => x.Active == true);

        if (activeBoats.Count() > 0)
        {
            Boat curActive = activeBoats.First();
            curActive.Active = false;
            curActive.Save();
            Sail activeSail = curActive.GetSailsBought().Where(x => x.Active).First();
            if (!b.GetSailsBought().Contains(activeSail))
            {
                activeSail.Active = false;
                activeSail.Save();
                Sail s = b.GetSailsBought().Where(x => x.Bought).First();
                s.Active = true;
                s.Save();
            }
        }
        b.Active = true;
        b.Save();
        UpdateBoatBuyPanels();
    }
Ejemplo n.º 27
0
    public void BuySail(Sail s)
    {
        if (MainGameController.instance.player.Gold >= s.Price)
        {
            Sail previousSail = MainGameController.instance.databaseController.connection.Table <Sail>().Where(x => x.Active).FirstOrDefault();
            if (previousSail != null)
            {
                previousSail.Active = false;
                previousSail.Save();
            }

            s.Bought = true;
            s.Active = true;
            s.Save();
            UpdateSailBuyPanels();
            MainGameController.instance.player.GiveGold(-s.Price);
            MainGameController.instance.player.Save();
            _goldText.text = MainGameController.instance.localizationManager.GetLocalizedValue("gold_text") + ": " + MainGameController.instance.player.Gold;
        }
        else
        {
            Debug.LogError("Not enough gold to buy sail!");
        }
    }
Ejemplo n.º 28
0
        private void LongDistanceNavigate(PlayerMove_Sail __instance)
        {
            VectorLF3 dir = target.GetDirection(__instance.player);

            Sail.SetDir(__instance, dir);

            VectorLF3 advisePoint = VectorLF3.zero;

            if (AdvisePointIfOcclusion(__instance, ref advisePoint, longNavUncoverRange))
            {
#if DEBUG
                ModDebug.Log("LongDistanceNavigate - ToAdvisePoint:" + advisePoint);
#endif

                dir = (advisePoint - __instance.player.uPosition).normalized;
                Sail.SetDir(__instance, dir);
                Sail.TrySpeedUp(this, __instance);
            }
            else if (Target.IsFocusingNormalized(dir, __instance.player.uVelocity.normalized) && !__instance.player.warping)
            {
                if (__instance.player.mecha.coreEnergy >= wrapEnergylimit && Warp.TryWrap(this, __instance))
                {
#if DEBUG
                    ModDebug.Log("Enter Wrap");
#endif
                    return;
                }
                else if (IsCurNavPlanet && target.IsLocalStarPlanet == true)
                {
#if DEBUG
                    ModDebug.Log("Local Planet Navigate No Wrap Chance SpeedUp");
#endif
                    Sail.TrySpeedUp(this, __instance);
                    return;
                }
                else if (LongDistanceNavigateNeedSpeedUp())
                {
#if DEBUG
                    ModDebug.Log("Long Distance Navigate Need SpeedUp");
#endif
                    Sail.TrySpeedUp(this, __instance);
                }
                else
                {
#if DEBUG
                    ModDebug.Log("Long Distance Navigate No SpeedUp And Warp");
#endif
                }
            }

            bool LongDistanceNavigateNeedSpeedUp()
            {
                if (__instance.player.mecha.coreEnergy >= speedUpEnergylimit)
                {
                    if (__instance.player.mecha.thrusterLevel < THRUSTER_LEVEL_WARP)
                    {
                        return(true);
                    }
                    //else if (Warp.GetWarperCount(__instance) <= 0)
                    else if (!Warp.HasWarper(__instance))
                    {
                        return(true);
                    }
                    return(true);
                }
                //Prepare warp
                if (__instance.player.mecha.coreEnergy < wrapEnergylimit)
                {
                    return(false);
                }
                return(false);
            }
        }
Ejemplo n.º 29
0
    private static bool Prefix
    (
        Sail __instance,
        ref bool ___blockPlaced,
        ref Network_Player ___localPlayer,
        ref CanvasHelper ___canvas,
        ref bool ___isRotating,
        ref GameObject ___paintCollider,
        ref Semih_Network ___network
    )
    {
        if (!___blockPlaced)
        {
            return(false);
        }
        if (___canvas == null || ___canvas.displayTextManager == null || ___localPlayer == null)
        {
            return(false);
        }
        if (Helper.LocalPlayerIsWithinDistance(__instance.transform.position, Player.UseDistance) && CanvasHelper.ActiveMenu == MenuType.None)
        {
            bool mod = MyInput.GetButton("Sprint");
            if (!__instance.open)
            {
                if (mod)
                {
                    ___canvas.displayTextManager.ShowText("Open Sails", MyInput.Keybinds["Interact"].MainKey, 1, "Rotate Sails", MyInput.Keybinds["Rotate"].MainKey, 2);
                }
                else
                {
                    ___canvas.displayTextManager.ShowText("Hold for more options", MyInput.Keybinds["Sprint"].MainKey, 1, "Open", MyInput.Keybinds["Interact"].MainKey, 2, 0, true);
                    ___canvas.displayTextManager.ShowText("Rotate", MyInput.Keybinds["Rotate"].MainKey, 3, 0, false);
                }
            }
            else
            {
                if (mod)
                {
                    ___canvas.displayTextManager.ShowText("Close Sails", MyInput.Keybinds["Interact"].MainKey, 1, "Rotate Sails", MyInput.Keybinds["Rotate"].MainKey, 2);
                }
                else
                {
                    ___canvas.displayTextManager.ShowText("Hold for more options", MyInput.Keybinds["Sprint"].MainKey, 1, "Close", MyInput.Keybinds["Interact"].MainKey, 2, 0, true);
                    ___canvas.displayTextManager.ShowText("Rotate", MyInput.Keybinds["Rotate"].MainKey, 3, 0, false);
                }
            }

            if (MyInput.GetButtonDown("Interact"))
            {
                Message_NetworkBehaviour message = new Message_NetworkBehaviour(__instance.open ? Messages.Sail_Close : Messages.Sail_Open, __instance);
                if (Semih_Network.IsHost)
                {
                    if (__instance.open)
                    {
                        if (mod)
                        {
                            MoreSailsMoreSpeed.SailsClose();
                        }
                        else
                        {
                            AccessTools.Method("Sail:Close").Invoke(__instance, null);
                        }
                    }
                    else
                    {
                        if (mod)
                        {
                            MoreSailsMoreSpeed.SailsOpen();
                        }
                        else
                        {
                            AccessTools.Method("Sail:Open").Invoke(__instance, null);
                        }
                    }
                    ___network.RPC(message, Target.Other, EP2PSend.k_EP2PSendReliable, NetworkChannel.Channel_Game);
                }
                else
                {
                    ___network.SendP2P(___network.HostID, message, EP2PSend.k_EP2PSendReliable, NetworkChannel.Channel_Game);
                }
            }

            if (MyInput.GetButton("Rotate"))
            {
                ___localPlayer.PlayerScript.SetMouseLookScripts(false);
                ___isRotating = true;
            }
            else if (MyInput.GetButtonUp("Rotate"))
            {
                if (mod)
                {
                    MoreSailsMoreSpeed.RotateSailsTo(__instance);
                }
                ___localPlayer.PlayerScript.SetMouseLookScripts(true);
                ___isRotating = false;
            }
            if (MyInput.GetButtonUp("Sprint") && ___isRotating)
            {
                MoreSailsMoreSpeed.RotateSailsTo(__instance);
                ___localPlayer.PlayerScript.SetMouseLookScripts(true);
                ___isRotating = false;
                return(false);
            }

            bool button = MyInput.GetButton("Rotate");
            if (button)
            {
                float axis = Input.GetAxis("Mouse X");
                if (Semih_Network.IsHost)
                {
                    AccessTools.Method("Sail:Rotate").Invoke(__instance, new object[] { axis });
                }
                else
                {
                    Message_Sail_Rotate message2 = new Message_Sail_Rotate(Messages.Sail_Rotate, __instance, axis);
                    ___network.SendP2P(___network.HostID, message2, EP2PSend.k_EP2PSendReliable, NetworkChannel.Channel_Game);
                }
            }
            ___paintCollider.SetActiveSafe(!button);
            return(false);
        }
        if (___isRotating)
        {
            ___isRotating = false;
            ___localPlayer.PlayerScript.SetMouseLookScripts(true);
        }
        ___canvas.displayTextManager.HideDisplayTexts();
        return(false);
    }
Ejemplo n.º 30
0
    private static bool Prefix
    (
        Raft __instance,
        ref Rigidbody ___body,
        ref float ___currentMovementSpeed,
        ref float ___speed,
        ref float ___maxDistanceFromAnchorPoint,
        ref StudioEventEmitter ___eventEmitter_idle,
        ref Vector3 ___previousPosition,
        ref Vector3 ___moveDirection,
        ref Vector3 ___anchorPosition
    )
    {
        if (!Semih_Network.IsHost)
        {
            return(false);
        }
        if (GameModeValueManager.GetCurrentGameModeValue().raftSpecificVariables.isRaftAlwaysAnchored)
        {
            return(false);
        }
        if (!__instance.IsAnchored)
        {
            if (___speed != 0f)
            {
                float openedSails = 0f;
                ___moveDirection = Vector3.forward;
                if (RaftVelocityManager.MotorDirection == Vector3.zero)
                {
                    List <Sail> allSails = Sail.AllSails;

                    Vector3 vector = Vector3.zero;

                    for (int i = 0; i < allSails.Count; i++)
                    {
                        Sail sail = allSails[i];
                        if (sail.open)
                        {
                            openedSails++;
                            vector += sail.GetNormalizedDirection();
                        }
                    }
                    if (vector.z < 0f)
                    {
                        if ((double)Mathf.Abs(vector.x) > 0.7)
                        {
                            vector.z = (___moveDirection.z = 0f);
                        }
                        else
                        {
                            vector.z = -0.8f;
                        }
                    }
                    ___moveDirection += vector;
                }
                else
                {
                    ___moveDirection = RaftVelocityManager.MotorDirection;
                }
                ___currentMovementSpeed = ___speed;
                if (RaftVelocityManager.MotorDirection != Vector3.zero)
                {
                    ___currentMovementSpeed = RaftVelocityManager.motorSpeed;
                    if (RaftVelocityManager.MotorWheelWeightStrength == MotorWheel.WeightStrength.Weak)
                    {
                        ___currentMovementSpeed *= 0.5f;
                    }
                    if (___currentMovementSpeed < ___speed)
                    {
                        ___currentMovementSpeed = ___speed;
                    }
                }
                else
                {
                    for (float i = 1; i < (openedSails + 1); i++)
                    {
                        ___currentMovementSpeed += (1.5f * (float)(i / Math.Pow(i, MoreSailsMoreSpeed.RaftFixedUpdatePatchRate)));
                    }
                }
                if (___speed != 0f)
                {
                    if (___currentMovementSpeed > __instance.maxSpeed)
                    {
                        ___currentMovementSpeed = __instance.maxSpeed;
                    }
                    ___moveDirection = Vector3.ClampMagnitude(___moveDirection, 1f);
                    ___body.AddForce(___moveDirection * ___currentMovementSpeed);
                }
            }
            List <SteeringWheel> steeringWheels = RaftVelocityManager.steeringWheels;
            float num = 0f;
            foreach (SteeringWheel steeringWheel in steeringWheels)
            {
                num += steeringWheel.SteeringRotation;
            }
            num = Mathf.Clamp(num, -1f, 1f);
            if (num != 0f)
            {
                Vector3 torque = new Vector3(0f, Mathf.Tan(0.0174532924f * num), 0f) * __instance.maxSteeringTorque;
                ___body.AddTorque(torque, ForceMode.Acceleration);
            }
        }
        else if (__instance.transform.position.DistanceXZ(___anchorPosition) > ___maxDistanceFromAnchorPoint)
        {
            Vector3 vector2 = ___anchorPosition - __instance.transform.position;
            vector2.y = 0f;
            ___body.AddForce(vector2.normalized * 2f);
        }
        if (___body.velocity.sqrMagnitude > __instance.maxVelocity)
        {
            ___body.velocity = Vector3.ClampMagnitude(___body.velocity, __instance.maxVelocity);
        }
        ___eventEmitter_idle.SetParameter("velocity", ___body.velocity.sqrMagnitude / __instance.maxVelocity);
        ___previousPosition = ___body.transform.position;
        return(false);
    }
Ejemplo n.º 31
0
        private static IUnit CreateUnit(UnitType type, int x, int y)
        {
            IUnit unit;

            switch (type)
            {
            case UnitType.Settlers: unit = new Settlers(); break;

            case UnitType.Militia: unit = new Militia(); break;

            case UnitType.Phalanx: unit = new Phalanx(); break;

            case UnitType.Legion: unit = new Legion(); break;

            case UnitType.Musketeers: unit = new Musketeers(); break;

            case UnitType.Riflemen: unit = new Riflemen(); break;

            case UnitType.Cavalry: unit = new Cavalry(); break;

            case UnitType.Knights: unit = new Knights(); break;

            case UnitType.Catapult: unit = new Catapult(); break;

            case UnitType.Cannon: unit = new Cannon(); break;

            case UnitType.Chariot: unit = new Chariot(); break;

            case UnitType.Armor: unit = new Armor(); break;

            case UnitType.MechInf: unit = new MechInf(); break;

            case UnitType.Artillery: unit = new Artillery(); break;

            case UnitType.Fighter: unit = new Fighter(); break;

            case UnitType.Bomber: unit = new Bomber(); break;

            case UnitType.Trireme: unit = new Trireme(); break;

            case UnitType.Sail: unit = new Sail(); break;

            case UnitType.Frigate: unit = new Frigate(); break;

            case UnitType.Ironclad: unit = new Ironclad(); break;

            case UnitType.Cruiser: unit = new Cruiser(); break;

            case UnitType.Battleship: unit = new Battleship(); break;

            case UnitType.Submarine: unit = new Submarine(); break;

            case UnitType.Carrier: unit = new Carrier(); break;

            case UnitType.Transport: unit = new Transport(); break;

            case UnitType.Nuclear: unit = new Nuclear(); break;

            case UnitType.Diplomat: unit = new Diplomat(); break;

            case UnitType.Caravan: unit = new Caravan(); break;

            default: return(null);
            }
            unit.X         = x;
            unit.Y         = y;
            unit.MovesLeft = unit.Move;
            return(unit);
        }
Ejemplo n.º 32
0
 /// <summary>
 /// give it a sail reference and the watermark locations
 /// </summary>
 /// <param name="m_sail">Sail reference</param>
 /// <param name="group">watermark group</param>
 internal void Prep(Sail sail, IRebuild group)
 {
     m_sail = sail;
     AutoFillVariables = m_sail.Watermark(group).ToList<object>();
 }
        public async Task <IHttpActionResult> mockData(int counter)
        {
            string[] Names     = { "Maggie", "Penny", "Magdalena", "Joanna", "Zuzanna", "Tomasz", "Marcin", "Jacek", "Mateusz", "Aleksander", "Jurek", "Abby", "Laila", "Sadie", "Olivia", "Ola", "Starlight", "Talla", "Zbigniew", "Jola" };
            string[] Surenames = { "Poloczek", "Nowak", "Cudzoziemiec", "Kwiatek", "K³y¿", "Ziêba", "Miodek", "Halama", "Nehru", "Boczek", "O³ówek", "Niestolik" };
            string[] City      = { "Sarnów", "Gorzów Wielkopolski", "Warszawa", "Kraków", "Katowice", "Gdañsk", "S³upsk", "Przemyœl", "Bielsko Bia³a", "¯ywiec", "Szczecin", "Poznañ" };
            string[] Email     = { "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**" };
            string[] Phones    = { "129483958", "837495837", "098273475", "283950392", "898127847", "988372982", "783917284" };
            try
            {
                for (int i = 0; i < counter; i++)
                {
                    int rand = new Random().Next(1, 6);
                    DomainModel.Advert advert = new DomainModel.Advert();
                    advert.AdditionDate          = DateTime.Now;
                    advert.AdditionalInformation = "Brak informacji dodatkowych na temat og³oszenia";
                    advert.City        = City[new Random().Next(0, 11)];
                    advert.Email       = Email[new Random().Next(0, 4)];
                    advert.FinishDate  = DateTime.Now.AddDays(7);
                    advert.Name        = Names[new Random().Next(0, 20)];
                    advert.PhoneNumber = Phones[new Random().Next(0, 6)];
                    advert.SureName    = Surenames[new Random().Next(1, 12)];
                    switch (rand)
                    {
                    case 1:
                        DomainModel.Engine subject = new DomainModel.Engine();
                        subject.Advert            = advert;
                        subject.AdvertDescription = "Sprzedam silnki u¿ywany, dwusuwowy.";
                        subject.AdvertName        = "Silnik mercury";
                        subject.Brand             = "Mercury";
                        subject.BuiltYear         = new Random().Next(1970, 2018).ToString();
                        subject.CategoryId        = 3;
                        subject.Power             = new Random().Next(1, 1000);
                        subject.Price             = new Random().Next(2000, 400000);
                        subject.TypeOfEngine      = DomainModel.Engine.EngineType.Outboard;
                        subject.TypeOfFuel        = DomainModel.Engine.FuelType.Gasoline;
                        DomainModel.Image uploadedImg = new DomainModel.Image();
                        int length = new Random().Next(1000, 99999);
                        uploadedImg.ImageData  = new byte[length];
                        uploadedImg.Name       = "silnikMercury";
                        uploadedImg.Identifier = Guid.NewGuid();
                        uploadedImg.Subject    = subject;
                        _db.images.Add(uploadedImg);
                        _db.SaveChanges();
                        break;

                    case 2:
                        DomainModel.Trailor subjectTrailor = new DomainModel.Trailor();
                        subjectTrailor.Advert            = advert;
                        subjectTrailor.AdvertDescription = "Sprzedam przyczepe u¿ywan¹ typu laweta.";
                        subjectTrailor.AdvertName        = "Przyczepa laweta";
                        subjectTrailor.Brand             = "Branderup";
                        subjectTrailor.BuiltYear         = new Random().Next(1970, 2018).ToString();
                        subjectTrailor.CategoryId        = 4;
                        subjectTrailor.Capcity           = new Random().Next(100, 40000);
                        subjectTrailor.Price             = new Random().Next(1500, 20000);
                        subjectTrailor.Length            = new Random().Next(4, 10);
                        subjectTrailor.Weight            = new Random().Next(100, 1000);
                        subjectTrailor.Width             = new Random().Next(1, 3);
                        DomainModel.Image uploadedImgTrailor = new DomainModel.Image();
                        int lengthTrailorImage = new Random().Next(1000, 99999);
                        uploadedImgTrailor.ImageData  = new byte[lengthTrailorImage];
                        uploadedImgTrailor.Name       = "Przyczepa";
                        uploadedImgTrailor.Identifier = Guid.NewGuid();
                        uploadedImgTrailor.Subject    = subjectTrailor;
                        _db.images.Add(uploadedImgTrailor);
                        _db.SaveChanges();
                        break;

                    case 3:
                        Boat     subjectBoat = new Boat();
                        SailBoat sailboat    = new SailBoat();
                        subjectBoat.AdvertDescription = "Sprzedam ¿aglówke, pierwszy w³aœciciel, jednomasztowa";
                        subjectBoat.AdvertName        = "Venuska";
                        subjectBoat.Price             = new Random().Next(1000, 99999);
                        subjectBoat.Advert            = advert;
                        sailboat.EnginePower          = new Random().Next(10, 888);
                        sailboat.EngineType           = 1;
                        sailboat.HullType             = "Kilowa";
                        sailboat.IsEngine             = true;
                        sailboat.RudderType           = "Rumpel";
                        sailboat.SailsArea            = new Random().Next(5, 40);
                        sailboat.YachtType            = "kilowy";
                        sailboat.Boat          = subjectBoat;
                        subjectBoat.CategoryId = 1;
                        subjectBoat.SailBoat   = sailboat;
                        DomainModel.Image uploadedImgSailboat = new DomainModel.Image();
                        int lengthSailboatImage = new Random().Next(1000, 99999);
                        uploadedImgSailboat.ImageData  = new byte[lengthSailboatImage];
                        uploadedImgSailboat.Name       = "£ódŸ ¿aglowa";
                        uploadedImgSailboat.Identifier = Guid.NewGuid();
                        uploadedImgSailboat.Subject    = subjectBoat;
                        _db.images.Add(uploadedImgSailboat);
                        _db.SaveChanges();
                        break;

                    case 4:
                        Boat      subjectMotorBoat = new Boat();
                        MotorBoat motorboat        = new MotorBoat();
                        subjectMotorBoat.AdvertDescription = "Sprzedam ¿aglówke, pierwszy w³aœciciel, jednomasztowa";
                        subjectMotorBoat.AdvertName        = "Venuska";
                        subjectMotorBoat.Price             = new Random().Next(1000, 99999);
                        subjectMotorBoat.Advert            = advert;
                        motorboat.EnginePower       = new Random().Next(10, 888);
                        motorboat.MotorboatType     = 1;
                        motorboat.Boat              = subjectMotorBoat;
                        subjectMotorBoat.CategoryId = 2;
                        subjectMotorBoat.MotorBoat  = motorboat;
                        DomainModel.Image uploadedImgMotorboat = new DomainModel.Image();
                        int lengthMotorboatImage = new Random().Next(1000, 99999);
                        uploadedImgMotorboat.ImageData  = new byte[lengthMotorboatImage];
                        uploadedImgMotorboat.Name       = "£ódŸ motorowdna";
                        uploadedImgMotorboat.Identifier = Guid.NewGuid();
                        uploadedImgMotorboat.Subject    = subjectMotorBoat;
                        _db.images.Add(uploadedImgMotorboat);
                        _db.SaveChanges();
                        break;

                    case 5:
                        Sail sails = new Sail();
                        sails.Advert            = advert;
                        sails.AdvertDescription = "";
                        sails.AdvertName        = "Sprzedam ¿agiel - u¿ywany";
                        sails.Brand             = "NorthSails";
                        sails.CategoryId        = 5;
                        sails.FootLenght        = new Random().Next(1, 3);
                        sails.LeechLenght       = new Random().Next(1, 6);
                        sails.LuffLenght        = new Random().Next(1, 6);
                        sails.Price             = new Random().Next(100, 1200);
                        sails.SailArea          = new Random().Next(2, 20);
                        DomainModel.Image uploadedImgSails = new DomainModel.Image();
                        int lengthSailsImage = new Random().Next(1000, 99999);
                        uploadedImgSails.ImageData  = new byte[lengthSailsImage];
                        uploadedImgSails.Name       = "¯agiel";
                        uploadedImgSails.Identifier = Guid.NewGuid();
                        uploadedImgSails.Subject    = sails;
                        _db.images.Add(uploadedImgSails);
                        _db.SaveChanges();
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                return(BadRequest());
            }



            return(Ok());
        }