Ejemplo n.º 1
0
    void Awake()
    {
        Director director = Director.GetInstance();

        director.currentSceneController = this;
        director.currentSceneController.loadResources();
        userGUI           = gameObject.AddComponent <UserGUI>() as UserGUI;
        userGUI.gameState = 0;
        ai = gameObject.AddComponent <AIcontroller>() as AIcontroller;
    }
Ejemplo n.º 2
0
    void Awake()
    {
        Director director = Director.getInstace();

        director.current = this;
        userGUI          = gameObject.AddComponent <UserGUI>() as UserGUI;
        characters       = new CharacterController[6];
        loadResources();
        //#########################
        actionManager = gameObject.AddComponent <Move> () as Move;
        ai            = gameObject.AddComponent <AIcontroller>() as AIcontroller;
    }
Ejemplo n.º 3
0
    void Start()
    {
        script = car.GetComponent <AIcontroller>();
        string path = Application.persistentDataPath + "/Text.txt";

        string[] savefile = File.ReadAllLines(path);
        path = Application.persistentDataPath + savefile[0];
        string[] weights = File.ReadAllLines(path);
        Debug.Log(path);
        Debug.Log(savefile[1]);
        int q = 0, nou = 0;

        while (q < savefile[1].Length)
        {
            nou = nou * 10 + savefile[1][q] - '0';
            q++;
        }
        gen = nou;
        Debug.Log(gen);
        int sign, nr, j = 0, i = gen * 2 - 1;

        for (int l = 1; l <= 3; l++)
        {
            for (int ii = 1; ii <= 4; ii++)
            {
                for (int jj = 1; jj <= 4; jj++)
                {
                    nr   = 0;
                    sign = 1;
                    while (j < weights[i].Length && weights[i][j] != ' ')
                    {
                        if (weights[i][j] == '-')
                        {
                            sign = -1;
                        }
                        if (weights[i][j] >= '0' && weights[i][j] <= '9')
                        {
                            nr = nr * 10 + weights[i][j] - '0';
                        }
                        j++;
                    }
                    j++;
                    script.a[l, ii, jj] = (float)(nr * sign) / 10000;
                    Debug.Log(script.a[l, ii, jj]);
                }
            }
        }
    }
Ejemplo n.º 4
0
    public bool human;     // indiciating whether or not the player is a bot/AI
    //public Rigidbody OurPlayer;
    //public Vector3 weaponOffset;
    //public float nextAttack;
    //protected bool iAttack;

    //List<Rigidbody> projectiles;



    //protected virtual void Attack() {}

    //protected virtual void Attack(Vector3 target) {}

    protected void start()
    {
        followCamera = cameraObject.GetComponent <FollowCamera>();
        weapon       = WeaponObject.GetComponent <Weapon>();
        if (human == false)
        {
            bot = OurPlayer.GetComponent <AIcontroller>();
        }

        //projectiles = new List<Rigidbody>();
        //GameObject weaponObject = Instantiate(WeaponObject, OurPlayer.transform.position + weaponOffset, Quaternion.identity) as GameObject;
        //WeaponObject.transform.position = OurPlayer.transform.position+weaponOffset; // move the weapon to the desired offset from the player
        //WeaponObject.transform.parent = OurPlayer.transform; // set the weapon object's transform to be a child of our player's transform.

        //nextAttack = attackRate;
        //Setup();
    }
Ejemplo n.º 5
0
    void Start()
    {
        rb            = car.GetComponent <Rigidbody2D>();
        col           = false;
        cur           = 1;
        max1          = 0f;
        max2          = 0f;
        generation    = 1;
        alive         = new int[13];
        fit           = new float[13];
        a             = new float[13, 4, 5, 5];
        rez           = new float[13, 4, 5, 5];
        probabilities = new float[13];
        ales          = new int[13];

        script = car.GetComponent <AIcontroller>();

        string path = Application.persistentDataPath + "/Text.txt";

        string[] savefile = File.ReadAllLines(path);
        if (savefile[1][0] - '0' == 1)
        {
            random();
        }
        else
        {
            load();
        }

        for (int l = 1; l <= 3; l++)
        {
            for (int i = 1; i <= 4; i++)
            {
                for (int j = 1; j <= 4; j++)
                {
                    script.a[l, i, j] = a[cur, l, i, j];
                }
            }
        }
    }
Ejemplo n.º 6
0
    private void movingState()
    {
        if (startMove)
        {
            if (dir == curDir)
            { // don't need to rotate
                if (!moving)
                {
                    Debug.Log("want to move");

                    destination = transform.position + transform.forward.normalized;
                    moving      = true;
                    audio [1].Play();
                }
                else
                {
                    if (Vector3.Distance(transform.position, destination) > 0.01f)
                    {
                        board.monsPosTable[(int)transform.position.x, (int)transform.position.z] = false;
                        Vector3 to = Vector3.MoveTowards(transform.position, destination, 10 * Time.deltaTime);
                        transform.position = to;
                    }
                    else
                    {
                        board.monsPosTable[(int)transform.position.x, (int)transform.position.z] = true;
                        arrived = true;
                        board.steps[playerIndex]--;
                        if (playerIndex == 1 && board.MoveMonsEnd)
                        {
                            AIcontroller ai = GameObject.FindGameObjectWithTag("AI").GetComponent <AIcontroller>();
                            ai.RotateBattleDir();
                        }
                        startMove   = false;
                        destination = transform.position;
                    }
                }
            }
            else if (!moving)
            {  // need to rotate
                Debug.Log("want to rotate");
                if (dir == 0)
                {
                    transform.rotation = Quaternion.LookRotation(Vector3.forward);
                    curDir             = 0;
                }
                else if (dir == 1)
                {
                    transform.rotation = Quaternion.LookRotation(Vector3.forward * -1);
                    curDir             = 1;
                }
                else if (dir == 2)
                {
                    transform.rotation = Quaternion.LookRotation(Vector3.right * -1);
                    curDir             = 2;
                }
                else if (dir == 3)
                {
                    transform.rotation = Quaternion.LookRotation(Vector3.right);
                    curDir             = 3;
                }
            }
            GetComponent <Animator>().Play("Walk");
        }
    }