Exemple #1
0
    // Use this for initialization
    protected void Start()
    {
        if (MyId.Contains("Dummy") || HType == H.Dummy)
        {
            return;
        }

        base.Start();

        //print("b4 gen Uni#:" + General.UnivRotationFacer);
        //print("facer#:" + RotationFacerIndex);

        //the dummys one dont need rotation other wise will screw the BuildingPot.Control.CurrentSpawnBuild
        if (b.CurrentSpawnBuild != null && HType != H.Dummy)
        {
            b.CurrentSpawnBuild.transform.Rotate(0, RotationFacerIndex * 90, 0);
        }
        //here bz need to be called afer rotartion of building happens
        HandleSavedTownBuilding();

        //so bounds get updateds
        CheckIfIsEvenRoutine();

        if (!IsLoadingFromFile && HType != H.BullDozer)
        {
            CreateArrow();
        }
    }
        public void TestIdEquality()
        {
            var anId      = MyId.FromString("myIdValue");
            var anotherId = MyId.FromString("myIdValue");

            Assert.True(anId.Equals(anotherId));
        }
Exemple #3
0
        public void ParseFromString(string s)
        {
            ClearField();

            var split = s.Split(',');
            var x     = 0;
            var y     = 0;

            foreach (var value in split)
            {
                FieldPositions[x][y] = value;

                if (value != BotConstants.Wall && value != BotConstants.Free)
                {
                    if (value.Equals(MyId.ToString()))
                    {
                        MyPosition = new Point(x, y);
                    }
                    else
                    {
                        EnemyPosition = new Point(x, y);
                        EnId          = Int32.Parse(value);
                    }
                }

                if (++x == Width)
                {
                    x = 0;
                    y++;
                }
            }
        }
        public void TestIdValue()
        {
            const string myIdValue = "myIdValue";
            var          id        = MyId.FromString(myIdValue);

            id.Should().NotBeNull();
            id.Value.Should().NotBeNull();
            id.Value.Should().Be(myIdValue);
        }
        public void TestIdCreationFromGuid()
        {
            var myIdValue = Guid.NewGuid();
            var id        = MyId.FromGuid(myIdValue);

            id.Should().NotBeNull();
            id.Value.Should().NotBeNull();
            id.Value.Should().Be(myIdValue.ToString());
        }
        public void TestNewIdCreation()
        {
            var anId      = MyId.New();
            var anotherId = MyId.New();

            anId.Should().NotBeNull();
            anotherId.Should().NotBeNull();
            Assert.False(anId.Equals(anotherId));
        }
Exemple #7
0
    string ReturnMatBase()
    {
        if (MyId.Contains("Farm"))
        {
            return(Root.matBuildingBase2);
        }

        return(Root.matBuildingBase3);
    }
Exemple #8
0
    // Use this for initialization
    public void Start()
    {
        if (_hasStart)
        {
            return;
        }


        _hasStart  = true;
        _startTime = Time.time;

        _billBoardGO = GetChildThatContains("Billboard", gameObject);

        //only will be used for palms
        for (int i = 0; i < 4; i++)
        {
            var gO = GetChildThatContains("Object" + i, gameObject);
            if (gO != null)
            {
                //wont be null if a palm
                _collObjects.Add(gO);
            }
        }

        StartCoroutine("TenSecUpdate");
        Name = HType + "";

        if (MyId.Contains("Decora"))
        {
            return;
        }

        UpdateMinAndMaxVar();
        var bou = FindBounds(_min, _max);

        Anchors = FindAnchors(bou);

        if (!AmIValid())
        {
            return;
        }

        InitTree();
        addCrystals = true;
        AddCrystalsStart();
        base.Start();//intended to call TerrainRandomSpawner.cs

        if (ReplantedTree)
        {
            ReplantThisTree();
        }

        LoadGrowingTree();
    }
Exemple #9
0
    private void CreateFarm()
    {
        if (_farm != null)
        {
            return;
        }

        if (MyId.Contains("FieldFarm"))
        {
            _farm = new FieldFarm(this);
            //Debug.Log("new farm");
        }
    }
Exemple #10
0
    /// <summary>
    /// When a worker works in a farm
    /// </summary>
    public void AddWorkToFarm()
    {
        //in case is redoing farm
        if (_farm == null)
        {
            return;
        }

        if (MyId.Contains("FieldFarm"))
        {
            _farm.AddWorkToFarm();
        }
    }
Exemple #11
0
    //so a new farm can be created
    internal void DestroyFarm()
    {
        if (MyId.Contains("FieldFarm"))
        {
            var field = (FieldFarm)_farm;
            field.BatchDestroy();
        }

        _farm = null;

        //just in case was harvested, lets reload all
        //this is for Stats so its reloads
        ReloadInventory();
    }
Exemple #12
0
    // Update is called once per frame
    protected void Update()
    {
        //if is dummy doesnt need to be raycasting th blue rays all the time etc
        if (HType == H.Dummy)
        {
            return;
        }

        if (_arrow != null)
        {
            if (_arrow.transform.position != ReturnArrowIniPos(1.75f) && Bounds.Count > 0)
            {
                _arrow.transform.position = Vector3.Lerp(_arrow.transform.position, ReturnArrowIniPos(1.75f), 0.5f);
            }
        }

        UpdateFarm();


        base.Update();
        if (!PositionFixed)
        {
            //Will destroy the current obj if in Building._isOrderToDestroy is set to true
            //and PersonController is -1
            DestroyOrdered();
        }
        else if (PositionFixed && CurrentStage == 0)
        {
            if (_startingStage == H.None)
            {
                ShowNextStage();
            }
            else if (_startingStage != H.None && CurrentStage == 0)
            {
                RecreateStage();
            }
        }

        if (PositionFixed && PeopleDict.Count > 0 && MyId.Contains("Farm") && CurrentProd != null)
        {
            CreateFarm();
        }

        if (PlantSave1 != null && IsLoadingFromFile && _farm == null)
        {
            _farm             = new FieldFarm(this, PlantSave1);
            IsLoadingFromFile = false;
        }
    }
Exemple #13
0
    private void UpdateFarm()
    {
        if (_farm != null)
        {
            if (MyId.Contains("FieldFarm"))
            {
                var ff = (FieldFarm)_farm;
                ff.Update();

                if (_isOrderToDestroy)
                {
                    ff.BatchDestroy();
                }
            }
        }
    }
Exemple #14
0
    private void CreateArrow()
    {
        if (b.CurrentSpawnBuild == null || _arrow != null || MyId.Contains(H.Dummy.ToString()) ||
            b.CurrentSpawnBuild.IsSmallBuilding())
        {
            return;
        }

        _arrow = Create(Root.arrow, new Vector3());
        _arrow.transform.Rotate(0, RotationFacerIndex * 90, 0);
        _arrow.transform.SetParent(b.CurrentSpawnBuild.transform);

        if (Bounds.Count > 0)
        {
            _arrow.transform.position = ReturnArrowIniPos(1.75f);
        }
    }
Exemple #15
0
            public MemoryCell(Random rSeed, Context.SEAContext.DoHandler doCallback, ref StringBuilder key)
            {
                id   = MyId.NewId(rSeed.Next());
                cell = new StringBuilder(CELL_LENGHT, CELL_LENGHT);
                id.AppendTo(ref key);
                id.AppendTo(ref cell);
                cell.Append(FLAG_VOID);
                id.AppendTo(ref cell);

                cell.Length    = CELL_LENGHT;
                this.doCommand = doCallback;

                reader = new Reader();
                writer = new Writer();

                listener = new ActionTimer();
                listener.Start(Translate);
            }
Exemple #16
0
    public override IEnumerator SlowUpdate()
    {
        if (IsServer)
        {
            //while(all players have not hit ready)
            //Wait

            //SendUpdate "GAMESTART"

            //Go to each NetworkPlayerManager and look at their options
            //Create the appropriate character for their options
            //GameObject temp = MyCore.NetCreateObject(1,Owner,new Vector3);
            //temp.GetComponent<MyCharacterScript>().team = //set the team;

            MyId.NotifyDirty();
        }
        yield return(new WaitForSeconds(.1f));
    }
        public Board MacroBoard()
        {
            var board = new Board();

            board.Grid = new Cell[3, 3];

            var myString       = MyId.ToString();
            var opponentString = OpponentId.ToString();

            for (int y = 0; y < 3; y++)
            {
                for (int x = 0; x < 3; x++)
                {
                    var       test = macroboard[x, y];
                    CellState state;

                    if (test == myString)
                    {
                        state = CellState.Me;
                    }
                    else if (test == opponentString)
                    {
                        state = CellState.Opponent;
                    }
                    else if (test == AvailableField)
                    {
                        state = CellState.Playable;
                    }
                    else
                    {
                        state = CellState.Undefined;
                    }

                    board.Grid[x, y] = new Cell()
                    {
                        State = state
                    };
                }
            }

            return(board);
        }
        public Board MicroBoard(int macroX, int macroY)
        {
            var b = new Board();

            b.Grid = new Cell[3, 3];

            var myString       = MyId.ToString();
            var opponentString = OpponentId.ToString();

            for (int y = 0; y < 3; y++)
            {
                for (int x = 0; x < 3; x++)
                {
                    var       test = board[x + macroX * 3, y + macroY * 3];
                    CellState state;


                    if (test == myString)
                    {
                        state = CellState.Me;
                    }
                    else if (test == opponentString)
                    {
                        state = CellState.Opponent;
                    }
                    else
                    {
                        state = CellState.Playable;
                    }

                    b.Grid[x, y] = new Cell()
                    {
                        State = state
                    };
                }
            }

            return(b);
        }
        public Board FullBoard()
        {
            var b = new Board {
                Grid = new Cell[9, 9]
            };

            var myString       = MyId.ToString();
            var opponentString = OpponentId.ToString();

            for (int y = 0; y < 9; y++)
            {
                for (int x = 0; x < 9; x++)
                {
                    var       test = board[x, y];
                    CellState state;

                    if (test == myString)
                    {
                        state = CellState.Me;
                    }
                    else if (test == opponentString)
                    {
                        state = CellState.Opponent;
                    }
                    else
                    {
                        state = CellState.Playable;
                    }

                    b.Grid[x, y] = new Cell()
                    {
                        State = state
                    };
                }
            }
            return(b);
        }
Exemple #20
0
 public ClassWithRef(MyId id)
 {
     _id = id;
 }
Exemple #21
0
    //NOTE: SaveDataInDb() method will save all the member'fields in DB
    //and also will check an Email Id is already exist or not
    //Will return true if not exist and false if exist

    private void SaveDataInDb(RequiredFieldValidator validatorEmail, Label lblError)
    {
        string selectSqlQuery = "SELECT CustEmailAddr";

        selectSqlQuery += "WHERE CustEmailAddr = @CustEmailAddr";

        string insertSqlQuery = "INSERT INTO customer (";

        insertSqlQuery += "CustId, CustFirstName, CustLastName, CustPwd, CustMobNo, CustEmailAddr) ";
        insertSqlQuery += "VALUES (";
        insertSqlQuery += "@CustId, @CustFirstName, @CustLastName, @CustPwd, @CustMobNo, @CustEmailAddr )";

        MySqlConnection connection = new MySqlConnection(connectionString);

        MySqlCommand cmd = new MySqlCommand(selectSqlQuery, connection);

        MySqlCommand cmdInsert = new MySqlCommand(insertSqlQuery, connection);

        MySqlDataAdapter adapter = new MySqlDataAdapter();

        MySqlDataReader reader;

        // Add the parameters
        cmdInsert.Parameters.AddWithValue("@CustId", MyId);

        cmd.Parameters.AddWithValue("@CustEmailAddr", EmailId);

        cmdInsert.Parameters.AddWithValue("@CustFirstName", CustFirstName);

        cmdInsert.Parameters.AddWithValue("@CustLastName", CustLastName);

        cmdInsert.Parameters.AddWithValue("@CustPwd", GetPwd);

        cmdInsert.Parameters.AddWithValue("@CustMobNo", CustMobNo);

        cmdInsert.Parameters.AddWithValue("@CustEmailAddr", EmailId);

        //Will use Try & catch block to be suscessful connection
        int added = 0;

        try
        {
            //To dispose the connection Obj successfully

            using (connection)
            {
                //Open Databse connection
                connection.Open();
                reader = cmd.ExecuteReader();

                //Will check an Email id is already exist or not

                while (reader.Read())
                {
                    //If exist

                    if (EmailId == reader["CustEmailAddr"].ToString())
                    {
                        validatorEmail.Text  = "Email Id is already exist";
                        validatorEmail.Text += "Click on forgot password";
                    }

                    //If not

                    else
                    {
                        //If inserted successfully it returns 1

                        added = cmdInsert.ExecuteNonQuery();
                    }
                }
            }
        }
        catch (Exception error)
        {
            lblError.Text = error.ToString();
        }

        //If record is added sucessfully set cookie and mail info to client

        if (added > 0)
        {
            //Create cookie
            cookie = new HttpCookie("CustomerInfo");

            // Store CustId to cookie
            cookie["CustId"] = MyId.ToString();
            cookie.Expires   = DateTime.Now.AddDays(2);

            //Add it to the current web response
            System.Web.HttpContext.Current.Response.Cookies.Add(cookie);

            //Navigate customer to home page
            System.Web.HttpContext.Current.Response.Redirect("Home.aspx");

            //Mail info to client
            SendSignUpMail();
        }
    }
 public bool IsMe(int x, int y)
 {
     return(board[x, y] == MyId.ToString());
 }
    public bool Login()
    {
        HttpCookie cookie;

        string selectSqlQueryCust = "SELECT  CustId, CustEmailAddr, CustPwd FROM customer ";

        selectSqlQueryCust += "WHERE CustEmailAddr = @CustEmailAddr";

        string selectSqlQueryAdmin = "SELECT AdminId, AdminName,  AdminEmailAddr, AdminPwd FROM admin ";

        selectSqlQueryAdmin += "WHERE AdminEmailAddr = @AdminEmailAddr";

        bool readerResult = false;

        MySqlConnection connection = new MySqlConnection(connectionString);

        MySqlCommand cmd;

        MySqlDataAdapter adaptor;

        MySqlDataReader reader;

        if (objSelection == SelectionChoice.Customer)
        {
            cmd = new MySqlCommand(selectSqlQueryCust, connection);

            //Add the paramaters
            cmd.Parameters.AddWithValue("@CustEmailAddr", EmailId);
            //  adaptor = new MySqlDataAdapter(cmd);
        }
        else
        {
            cmd = new MySqlCommand(selectSqlQueryAdmin, connection);

            //Add the parameters
            cmd.Parameters.AddWithValue("@AdminEmailAddr", EmailId);

            //  adaptor = new MySqlDataAdapter(cmd);
        }

        try
        {
            //To automatically dispose the connction Obj
            using (connection)
            {
                // Open the database connection
                connection.Open();
                reader = cmd.ExecuteReader();

                switch (objSelection)
                {
                case SelectionChoice.Customer:

                    //Read the data from Customer table
                    //If matches the given EmailId and password return true
                    while (reader.Read())
                    {
                        if (EmailId == reader["CustEmailAddr"].ToString() && GetPwd == reader["CustPwd"].ToString())
                        {
                            MyId = Convert.ToInt32(reader["CustId"].ToString());

                            // Create the cookie
                            cookie = new HttpCookie("CustomerInfo");

                            //Set value to cookie
                            cookie["CustId"] = MyId.ToString();

                            //Add cookie to web browser with validaty
                            cookie.Expires = DateTime.Now.AddDays(2);
                            System.Web.HttpContext.Current.Response.Cookies.Add(cookie);

                            //Navigate customer to home page
                            //   System.Web.HttpContext.Current.Response.Redirect("Home.aspx");
                            readerResult = true;
                        }
                    }
                    break;

                case SelectionChoice.Admin:

                    while (reader.Read())
                    {
                        if (EmailId == reader["AdminEmailAddr"].ToString() && GetPwd == reader["AdminPwd"].ToString())
                        {
                            MyId = Convert.ToInt32(reader["AdminId"]);

                            Name = reader["AdminName"].ToString();
                            // Create the cookie
                            cookie = new HttpCookie("AdminInfo");

                            //Set value to cookie
                            cookie["AdminId"]   = MyId.ToString();
                            cookie["AdminName"] = Name;

                            //Add cookie to web browser with validaty
                            cookie.Expires = DateTime.Now.AddDays(2);
                            System.Web.HttpContext.Current.Response.Cookies.Add(cookie);

                            ////Navigate customer to home page
                            //System.Web.HttpContext.Current.Response.Redirect("AdminOrder.aspx");
                            readerResult = true;
                        }
                    }
                    break;

                default:
                    break;
                }
            }
        }
        catch (Exception error)
        {
            Label errorLbl = new Label();
            System.Diagnostics.Debug.WriteLine("Database Error Message", error);
            errorLbl.Text = error.ToString();
        }
        return(readerResult);
    }
    //NOTE: SaveDataInDb() method will save all the member'fields in DB
    //and also will check an Email Id is already exist or not
    //Will return true if not exist and false if exist

    private bool SaveDataInDb()
    {
        HttpCookie cookie;

        bool signupStatus = true;

        string selectSqlQuery = "SELECT * FROM customer ";

        selectSqlQuery += " WHERE CustEmailAddr = @CustEmailAddr";

        string insertSqlQuery = "INSERT INTO customer (";

        insertSqlQuery += "CustId, CustFirstName, CustLastName, CustPwd, CustMobNo, CustEmailAddr, CustImg ) ";
        insertSqlQuery += "VALUES (";
        insertSqlQuery += "@CustId, @CustFirstName, @CustLastName, @CustPwd, @CustMobNo, @CustEmailAddr, @CustImg )";

        MySqlConnection connection = new MySqlConnection(connectionString);

        MySqlCommand cmd = new MySqlCommand(selectSqlQuery, connection);

        MySqlCommand cmdInsert = new MySqlCommand(insertSqlQuery, connection);

        // MySqlDataAdapter adapter = new MySqlDataAdapter();

        MySqlDataReader readerSignup;

        //Add parameters for Selct
        cmd.Parameters.AddWithValue("@CustEmailAddr", EmailId);

        // Add the parameters for insert
        cmdInsert.Parameters.AddWithValue("@CustId", MyId);

        cmdInsert.Parameters.AddWithValue("@CustEmailAddr", EmailId);

        cmdInsert.Parameters.AddWithValue("@CustFirstName", CustFirstName);

        cmdInsert.Parameters.AddWithValue("@CustLastName", CustLastName);

        cmdInsert.Parameters.AddWithValue("@CustPwd", GetPwd);

        cmdInsert.Parameters.AddWithValue("@CustMobNo", CustMobNo);

        cmdInsert.Parameters.AddWithValue("@CustImg", CustImg);

        //  cmdInsert.Parameters.AddWithValue("@CustEmailAddr", EmailId);

        //Will use Try & catch block to be suscessful connection
        int added = 0;

        try
        {
            //To dispose the connection Obj successfully

            using (connection)
            {
                //Open Databse connection
                connection.Open();

                readerSignup = cmd.ExecuteReader();

                //Will check an Email id is already exist or not

                while (readerSignup.Read())
                {
                    //If exist

                    if (EmailId == readerSignup["CustEmailAddr"].ToString())
                    {
                        signupStatus = false;
                        //validatorEmail.Text = "Email Id is already exist";
                        //validatorEmail.Text += "Click on forgot password";
                    }
                }

                //Insert record if no existing user in Database
                if (signupStatus)
                {
                    readerSignup.Close();
                    added = cmdInsert.ExecuteNonQuery();
                }
            }
        }
        catch (Exception error)
        {
            System.Diagnostics.Debug.WriteLine("Sign up Error" + error);
        }

        //If record is added sucessfully set cookie and mail info to client

        if (added > 0)
        {
            //Create cookie
            cookie = new HttpCookie("CustomerInfo");

            // Store CustId to cookie
            cookie["CustId"] = MyId.ToString();
            cookie.Expires   = DateTime.Now.AddDays(2);

            //Add it to the current web response
            System.Web.HttpContext.Current.Response.Cookies.Add(cookie);

            //Navigate customer to home page
            //  System.Web.HttpContext.Current.Response.Redirect("Home.aspx");

            //Mail info to client
            SendSignUpMail();

            signupStatus = true;
        }

        return(signupStatus);
    }