Наследование: MonoBehaviour
Пример #1
0
    public GameObject Floor;                // is the game object block that is used to create a path

    // Use this for initialization
    private void Start()
    {
        transform.eulerAngles = Vector3.zero;
        _self = this;                                                                                                                                                                       //loade this script
        Land.SetEndPoint(LandManager.CreateNext(LandManager.CreateNext(LandManager.CreateNext(LandManager.CreateNext(LandManager.CreateNext(startPoint, 0)[0], 0)[0], 0)[0], 0)[0], 0)[0]); //add 5 straight blocks when the game starts
        _prep           = false;                                                                                                                                                            //set the preperation bool to false
        PlayerTransform = GameObject.FindGameObjectWithTag("Player").transform;                                                                                                             //adding positions to the player
    }
Пример #2
0
 void Awake()
 {
     if (instance != null)
     {
         Debug.LogError("there is more than 1 landmanager in scene");
         return;
     }
     instance = this;
 }
Пример #3
0
    // Use this for initialization
    void Start()
    {
        if (Instance != null)
        {
            UnityEngine.Debug.LogError("EthKeyManager is already set. Additional EthKeyManager dit not get started.");
            return;
        }

        LandManager = GetComponent <LandManager>();

        if (string.IsNullOrEmpty(RpcUrl))
        {
            //RpcUrl = "http://localhost:9545";
            //RpcUrl = "http://116.203.118.82:8545";
            //RpcUrl = "https://rpc.tau1.artis.network";
            RpcUrl = "http://40.71.213.163:8545";
        }

        //if (!string.IsNullOrEmpty(PreselectedPrivateKey))
        //{
        //    privateKey = PreselectedPrivateKey;
        //}



        Wallet = new Nethereum.HdWallet.Wallet(Words, Password);

        Account = Wallet.GetAccount(0);



        Debug.Log("Address: " + Account.Address);
        //Wallet.GetAccount(0);
        //todo: find out how to create Key Pair
        Web3 = new Nethereum.Web3.Web3(Account, RpcUrl);


        Web3.Eth.TransactionManager.DefaultGas      = new BigInteger(1000000);
        Web3.Eth.TransactionManager.DefaultGasPrice = new BigInteger(1000000000);
        // Account.TransactionManager.DefaultGas

        //WorldsRegistry = new Galleass3D.Contracts.WorldsRegistry.WorldsRegistryService(Web3, WorldsRegistryAddress);



        //TODO: find out how to call a async function on purpose.
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
        StartBlockchainCommunication();
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
    }
Пример #4
0
 public Lands(LandManager manager)
 {
     _manager = manager;
 }
Пример #5
0
    void OnTriggerEnter(Collider collider) //when the player enters the collider
    {
        _swipe.land = this;
        Land standing = this;                      //to start with the one the player stands on

        while (standing.Root != null)              // keep counting one block backwards
        {
            standing = standing.Root;              // till it finds the first block and set it
        }
        standing.lastActivId = lastActivCounter++; //give id to the last activated block



        if (collider.gameObject.tag == "Player" && GetComponents <BoxCollider>()[2].enabled == true) //when the player enters the rotate collider
        {
            rotate = true;                                                                           //set the bool to true
        }



        if (_isCrossway)         //if the roade is crossy
        {
            _isCrossway = false; //set the bool to false
        }


        int counter = transform.GetComponentsInChildren <Land>().Length;

        //   print("test counter: " + counter);
        if (counter >= 7)    //if there are more then 7 blocks after this block
        {
            //stop creating new blocks
            return;
        }


        if (transform.childCount >= 5)    //if there are more then 5 blocks
        {
            _isCrossway = true;           //that means it is a cross Roade
        }

        if (collider.gameObject.tag == "Player") //if the player enters the collider
        {
            if (EndPoints != null)               //if there is an end point
            {
                // print(EndPoints.Count);

                List <Land> temp = new List <Land>();  //create temperarly list to delete later
                while (EndPoints.Count > 0)            //as long as there is an end point
                {
                    if (EndPoints[0] == null)
                    {
                        EndPoints.RemoveAt(0);
                        continue;
                    }
                    print("after if there is" + temp.Count);
                    if (EndPoints[0]._nextStraight)                             //if the straight bool is true
                    {
                        temp.AddRange(LandManager.CreateNext(EndPoints[0], 0)); //add a block with a straight case
                    }
                    else                                                        //if not true
                    {
                        if (GetPossibleDirections(EndPoints[0]).Length > 0)
                        {
                            temp.AddRange(LandManager.CreateNext(EndPoints[0], GetPossibleDirections(EndPoints[0]))); //add another block
                        }
                        else
                        {
                            print("Invalid Endpoint");
                        }
                    }



                    EndPoints.RemoveAt(0);  //after we created a block after the endpoint it no longer is an endpoint, so we remove it
                }
                if (temp.Count == 0)
                {
                    throw new System.Exception("end of endpoints");
                }

                // if there is more then one endpoint mix the order
                if (temp.Count > 1)
                {
                    List <Land> temp_mix = new List <Land>();
                    while (temp.Count > 0)
                    {
                        var rnd = Random.Range(0, temp.Count);
                        temp_mix.Add(temp[rnd]);
                        temp.RemoveAt(rnd);
                    }
                    temp.AddRange(temp_mix);
                }

                EndPoints = temp;                                                                       // save the new enpoints in the list
            }
            else                                                                                        //if the list is empty
            {
                EndPoints = LandManager.CreateNext(GetComponent <Land>(), GetPossibleDirections(this)); //add a land script to add a block
            }


            if (Root != null && Root.Root != null && Root.Root.Root != null) //if the last block is there and the one before
            {
                LandManager.DeleteLand(Root.Root.Root, Root.Root);           //delet and remove the one befor the last one
            }
        }

        LandManager.CheckForMultipleRoots();  //check if there is more then one roade
    }
Пример #6
0
 public void SetLandManager(LandManager landManager)
 {
     LandManager = landManager;
 }