Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        if (code == null)
        {
            code = gameObject.GetComponent <MainObject>().script;
        }

        Compiler.setCode(code);
        Compiler.compile();

        _ip = new Interpretor();
        _ip.setICode(Compiler.getICode());
        _ip.init();

        //-Debug.Log(code);


        //animation setup//
        anim = GetComponent <Animator>();
        if (anim == null)
        {
            anim = GetComponentInChildren <Animator>();
        }
        if (controller == null)
        {
            controller = GetComponent <CharacterController>();
        }
        if (controller == null)
        {
            controller = GetComponentInChildren <CharacterController>();
        }
        stats = gameObject.GetComponent <AnimalStats>();
        //stats.setType(0);
    }
Ejemplo n.º 2
0
 public Animal(Intelligence intel, AnimalStats stats, double width, double height) :
     base(intel, width, height)
 {
     Stats         = stats;
     Stamina       = Stats.MaxStamina;
     VisibleAnimal = new VisibleAnimal(this);
 }
Ejemplo n.º 3
0
    private void GenerateRandomSpawn(AnimalStats currentAnimalStats)
    {
        GameObject animalCreated;
        Vector2    spawnPoint = GenerateRandomSpawnPoint();

        animalCreated = Instantiate(_animalPrefab, spawnPoint, Quaternion.identity, _animalsParent);
        animalCreated.GetComponent <Animal>().stats = currentAnimalStats;
    }
Ejemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        //player = Data.
        controller = gameObject.GetComponent <CharacterController>();

        head  = GameObject.Find(gameObject.name + "/head");
        stats = this.GetComponent <AnimalStats>();
    }
Ejemplo n.º 5
0
 public StateBase(AnimalAIController controller, AnimalStats stats, Animator animator, NavMeshAgent navMeshAgent)
 {
     animalController  = controller;
     animalStats       = stats;
     currentAnimator   = animator;
     currentNavAgent   = navMeshAgent;
     CurrentStageEvent = Event.Enter;
 }
Ejemplo n.º 6
0
    //end of editor launch functions//
    void loadAnimal(int index)
    {
        GameObject obj = Data.objects[index];

        obj.AddComponent <AnimalAnimation>();
        AnimalStats aStats = obj.AddComponent <AnimalStats>();

        aStats.setType(obj.GetComponent <MainObject>().model);
    }
Ejemplo n.º 7
0
    void animal()
    {
        string code = "while(1<3){walk 10 left 90;}";
        //Data.currentCode = code;
        GameObject      animal = GameObject.Instantiate(Data.files[0].file);
        AnimalAnimation _aa    = animal.AddComponent <AnimalAnimation>();
        AnimalStats     __as   = animal.AddComponent <AnimalStats>();

        __as.setType(0);
    }
Ejemplo n.º 8
0
    // Use this for initialization
    void Start()
    {
        controller = gameObject.GetComponent <CharacterController>();


        animal = gameObject.ToString().Replace("(Clone)", "").Replace("UnityEngine.GameObject", "");
        head   = GameObject.Find(gameObject.name + "/head");
        Debug.Log(head.name);
        stats = this.GetComponent <AnimalStats>();
    }
 public AnimalStatus(AnimalData data, AnimalStats stats, List <Need> needs, Transform self, SpriteRenderer mood, Transform body)
 {
     Technet99m.TickingMachine.EveryTick += OnTick;
     this.data  = data;
     this.stats = stats;
     this.needs = needs;
     this.self  = self;
     this.mood  = mood;
     this.body  = body;
     OnTick();
 }
Ejemplo n.º 10
0
    // Use this for initialization
    void Start()
    {
        if (code == null)
        {
            code = gameObject.GetComponent <MainObject>().script;
        }

        Compiler.setCode(code);
        Compiler.compile();

        _ip = new Interpretor();
        _ip.setICode(Compiler.getICode());
        _ip.init();

        //animation setup//
        anim = GetComponent <Animator>();
        if (anim == null)
        {
            anim = GetComponentInChildren <Animator>();
        }
        if (controller == null)
        {
            controller = GetComponent <CharacterController>();
        }
        if (controller == null)
        {
            controller = GetComponentInChildren <CharacterController>();
        }
        stats  = gameObject.GetComponent <AnimalStats>();
        _speed = stats.walk_speed;
        //stats.setType(0);

        //TMP fun animation//
        vision = gameObject.GetComponent <VisionScript2>();
        if (vision == null)
        {
            vision = gameObject.AddComponent <VisionScript2>();
        }
        vision.setSpeed(stats.walk_speed);
        vision.setTurnSpeed(stats.turn_speed);
        vision.enabled = false;

        //add libraries.//
        SensingLib sl = gameObject.AddComponent <SensingLib>();

        sl.setInterpretor(_ip);

        //audio setup//
        audioSetup();

        //tmp code
        tantest();
    }
    public void DisplayCurrentAnimalStats(AnimalStats currentStats, GameObject currentAnimalGameObject)
    {
        _currentAnimalStats        = currentStats;
        _currentAnimalGameObject   = currentAnimalGameObject;
        _needsGarden.text          = (currentStats.HasGarden) ? ("Oui") : ("Non");
        _goodWithChildren.text     = (currentStats.HasChildren) ? ("Oui") : ("Non");
        _bestHomeType.text         = currentStats.HouseType.ToString();
        _monthlyCost.text          = currentStats.Cost.ToString();
        _goodWithOtherAnimals.text = (currentStats.HasOtherAnimals) ? ("Oui") : ("Non");
        _animalPersonality.text    = currentStats.AnimalPersonality.ToString();

        _canvasGroup.alpha        = 1f;
        _buttonsCanvasGroup.alpha = 1f;
    }
Ejemplo n.º 12
0
    public void ChooseAnimal(bool hasChosen, AnimalStats animalStats)
    {
        if (hasChosen)
        {
            _manager.placedAnimals.Add(animalStats, currentClient);
        }

        if (_manager.placedAnimals.Count == _manager.animals.Count)
        {
            EndGame();
        }

        ChooseRandomClient();
        _switchClientParc.Switch();
    }
Ejemplo n.º 13
0
    private void GenerateAnimalClientPair(int maxAnimals)
    {
        AnimalStats newAnimal;
        ClientStats newClient;

        for (int index = 0; index < maxAnimals; index += 1)
        {
            newAnimal = new AnimalStats();
            newClient = new ClientStats(newAnimal.HouseType, newAnimal.HasGarden, newAnimal.HasChildren,
                                        newAnimal.HasOtherAnimals, Random.Range(newAnimal.Cost, 2000), newAnimal.AnimalPersonality);
            _manager.animals.Add(newAnimal);
            _manager.clients.Add(newClient);
        }

        GenerateOtherClients(maxAnimals);
    }
Ejemplo n.º 14
0
    public static Animal NewAnimalOfKind(string kind, Transform parent, bool IgnoreName = false)
    {
        if (AnimalRef == null)
        {
            AnimalRef = Resources.Load <GameObject>("Animal");
        }
        Animal      animal = Object.Instantiate(AnimalRef, parent).GetComponent <Animal>();
        AnimalStats tmp    = Resources.Load <AnimalStats>($"Animals/{kind}/Stats");

        animal.Initialize(tmp);
        animal.GetComponent <AnimalAnimationController>().sprites = Resources.Load <AnimalSprites>($"Animals/{kind}/Sprites");
        if (IgnoreName)
        {
            return(animal);
        }
        PlayerPrefs.SetInt(nameKey + kind, PlayerPrefs.GetInt(nameKey + kind, 0) + 1);
        animal.data.name = kind + " #" + PlayerPrefs.GetInt(nameKey + kind);
        return(animal);
    }
Ejemplo n.º 15
0
    public void SetUp(string kind)
    {
        AnimalStats stats = Resources.Load <AnimalStats>($"Animals/{kind}/Stats");

        foreach (var f in stats.foods)
        {
            foods[(int)f].SetActive(true);
        }
        foreach (var s in stats.specials)
        {
            specials[(int)s].SetActive(true);
        }
        Name.text     = stats.kind;
        Icon.sprite   = Resources.Load <Sprite>($"Animals/{kind}/Icon");
        Price.text    = stats.price.ToString();
        preg.text     = Translator.TicksToTime(stats.TicksToBorn);
        grow.text     = Translator.TicksToTime(stats.TicksToFullMate);
        children.text = stats.minChildren == stats.maxChildren ? $"{stats.minChildren}" : $"{stats.minChildren}-{stats.maxChildren}";
    }
Ejemplo n.º 16
0
    private int ComputeCurrentAnimalClientPairPrefectStats(AnimalStats animal, ClientStats client)
    {
        int numberPerfectStats = 0;

        if (client.ClientPersonality != ClientPersonality.Bad)
        {
            if (animal.HouseType == client.HouseType)
            {
                numberPerfectStats += 1;
            }
            if (animal.HasGarden == client.HasGarden)
            {
                numberPerfectStats += 1;
            }
            if (animal.HasChildren == client.HasChildren)
            {
                numberPerfectStats += 1;
            }
            if (animal.HasOtherAnimals == client.HasOtherAnimals)
            {
                numberPerfectStats += 1;
            }
            if (animal.Cost <= client.Income)
            {
                numberPerfectStats += 1;
            }
            if (animal.AnimalPersonality == client.AnimalPersonalityWanted)
            {
                numberPerfectStats += 1;
            }
        }
        else
        {
            numberPerfectStats = -1;
        }

        return(numberPerfectStats);
    }
Ejemplo n.º 17
0
 public MoveToNextAreaState(AnimalAIController controller, AnimalStats animalStats, Animator animator, NavMeshAgent navMeshAgent) : base(controller, animalStats, animator, navMeshAgent)
 {
     CurrentStateName = States.MoveToNextArea;
 }
Ejemplo n.º 18
0
 public IdleState(AnimalAIController controller, AnimalStats animalStats, Animator animator, NavMeshAgent navMeshAgent) : base(controller, animalStats, animator, navMeshAgent)
 {
     CurrentStateName = States.Idle;
 }
Ejemplo n.º 19
0
 // Use this for initialization
 void Start()
 {
     animalStats = gameObject.GetComponent <AnimalStats>();
 }
Ejemplo n.º 20
0
 private void ApplyUpgrades(AnimalStats stats, int stage)
 {
 }
Ejemplo n.º 21
0
 public WalkAroundState(AnimalAIController controller, AnimalStats animalStats, Animator animator, NavMeshAgent navMeshAgent) : base(controller, animalStats, animator, navMeshAgent)
 {
     CurrentStateName = States.WalkAround;
 }