Example #1
0
        /// <summary>
        /// Throws the panel to the specified destination.
        /// </summary>
        /// <param name="destination">The destination.</param>
        protected void Throw(Point destination)
        {
            if (this.Throwable)
            {
                Size screenSize = this.GUI.SpriteRenderer.Viewport.Size;
                if (this.Left > 0 && this.Right < screenSize.Width && this.Top > 0 && this.Bottom < screenSize.Height)
                {
                    this.throwWayPoint = new WaypointController(this.Location)
                    {
                        Progression = Progression.Decreasing
                    };

                    // prevent throwing out of screen
                    if (destination.X < 0 ||
                        destination.X + this.Width > screenSize.Width ||
                        destination.Y < 0 ||
                        destination.Y + this.Height > screenSize.Height)
                    {
                        var lbc = new LiangBarskyClipping(new Rectangle(0, 0, screenSize.Width - this.Width, screenSize.Height - this.Height));
                        destination = lbc.ClipLineEndPoint(this.Location, destination);
                    }

                    this.throwWayPoint.AddWaypoint(destination, null);
                    this.throwWayPoint.Start(this.MiyagiSystem, true, c => this.Location = c);
                }
            }
        }
    void Start()
    {
        waypointController   = GetComponent <WaypointController>();
        zombieAnimator       = GetComponent <Animator>();
        sensor               = GetComponent <EnemySensor>();
        characterControl     = GetComponent <AICharacterControl>();
        attackRangeChecker   = GetComponent <AttackRangeChecker>();
        thirdPersonCharacter = GetComponent <ThirdPersonCharacter>();

        attackRangeChecker.enabled = false;

        //Add in animation events
        AnimationClip[] animationClips = zombieAnimator.runtimeAnimatorController.animationClips;
        foreach (AnimationClip clip in animationClips)
        {
            //We want to add a function to be called when the zombie attack is a place
            if (clip.name == "Zombie Attack")
            {
                AnimationEvent animationEvent = new AnimationEvent();
                animationEvent.functionName = "AttackAnimationComplete";
                //Animation time for a place where this could hit
                animationEvent.time = 1.13f;
                clip.AddEvent(animationEvent);
            }
            if (clip.name == "Zombie Death")
            {
                AnimationEvent animationEvent = new AnimationEvent();
                animationEvent.functionName = "DeathAnimationComplete";
                animationEvent.time         = clip.length;
                clip.AddEvent(animationEvent);
            }
        }
    }
Example #3
0
 private void Awake()
 {
     trigger            = GetComponent <SphereCollider>();
     waypointController = GetComponent <WaypointController>();
     animator           = GetComponent <Animator>();
     trigger.enabled    = false;
 }
Example #4
0
    private void Start()
    {
        meow_delay        = Random.Range(8, 26);
        entering_new_room = true;

        audio_controller     = GetComponent <AudioController>();
        sprite_renderer      = GetComponentInChildren <SpriteRenderer>();
        notification_display = GetComponentInChildren <NotificationDisplay>();
        notification_display.gameObject.SetActive(false);

        animator_component = GetComponentInChildren <Animator>();

        animator = Resources.Load <RuntimeAnimatorController>(
            $"Animations/Cats/{this.name}/{this.name + "CatAnimator"}");
        animator_component.runtimeAnimatorController = animator;

        animations.Add("Walking", $"{this.name + "WalkAnimation"}");
        animations.Add("Eating", $"{this.name + "EatAnimation"}");
        animations.Add("Standing", $"{this.name + "IdleAnimation"}");
        animations.Add("Sleeping", $"{this.name + "RelaxAnimation"}");

        state = new CatWalking(animator, animations["Walking"]);

        waypoint = GetRandomWaypoint(false);

        if (model.cats.Contains(this) == false)
        {
            model.cats.Add(this);
        }
    }
    WaypointController getNearestWaypoint(Vector2 origin, bool isWallIgnore = false)
    {
        WaypointController closestWaypoint = null;
        float closestDistance = 0;

        foreach (var waypoint in this.waypoints)
        {
            Vector2 wpPos = waypoint.transform.position;
            var     dist  = Vector2.Distance(origin, wpPos);
            if (closestWaypoint != null)   // TODO Implementasi WALL
            //int layerMask = 1 << LayerMask.NameToLayer("Layer 2"); // Layernya tembok
            //var raycast = Physics2D.Raycast(origin, (wpPos - origin).normalized, 100, layerMask);
            //bool isRaycastValid = raycast.collider == null;
            {
                bool isRaycastValid = true;
                bool isPossible     = isWallIgnore || isRaycastValid; // Check Raycast
                bool isCloser       = dist < closestDistance;
                if (!isPossible || !isCloser)
                {
                    continue;
                }
            }
            // Jika valid maka update closest
            closestWaypoint = waypoint;
            closestDistance = dist;
        }
        return(closestWaypoint);
    }
Example #6
0
    void Update()
    {
        if (target == null)
        {
            return;
        }
        transform.position = Vector2.MoveTowards(
            transform.position,
            target.transform.position,
            speed * Time.deltaTime
            );

        float distance = Vector2.Distance(
            target.transform.position,
            transform.position
            );

        if (distance <= 0)
        {
            if (target.end)
            {
                GameManager.instance.life -= 1;
                CanvasManager.instance.UpdateHUD();
                Destroy(gameObject);
            }
            else
            {
                currentWayPoint++;
                target = WaypointManager.instance.GetNext(currentWayPoint);
            }
        }
    }
Example #7
0
 void SetWaypoint()
 {
     currentWaypoint    = waypointNetwork.wayPoints[currentWaypointInList];
     currentDestination = new Vector3(currentWaypoint.transform.position.x, stateController.transform.position.y, currentWaypoint.transform.position.z);
     SetAnimatorToWalk();
     movementController.SetAgentDestination(currentDestination);
     isMovingToWaypoint = true;
 }
Example #8
0
 // Use this for initialization
 void Awake()
 {
     playerTransform          = GameObject.FindGameObjectWithTag("Player").transform;
     waypointControllerScript = GameObject.FindGameObjectWithTag("WaypointController").GetComponent <WaypointController>();
     closestWaypoint          = waypointControllerScript.FindClosestWaypoint(transform);
     if (decoy == false)
     {
         targetTransform = playerTransform;
     }
 }
Example #9
0
        public void ShowWaypointEditor(WaypointController waypoint)
        {
            if (ModelManager.Instance.Mode != ApplicationMode.Waypoints)
            {
                return;
            }

            waypointEditor.gameObject.SetActive(true);
            waypointEditor.Activate(waypoint);
        }
Example #10
0
 private void OnTriggerEnter(Collider col)
 {
     // detectando colisao com o waypoint
     if (col.CompareTag("Waypoint"))
     {
         WaypointController waypoint  = col.GetComponent <WaypointController>();
         WaypointController waypointP = waypoint.waypointP;
         followTarget.target = waypointP.transform;
     }
 }
Example #11
0
    private void ChangeToRoom(RoomController room)
    {
        this.room = room;
        waypoint  = GetRandomWaypoint(true);

        gameObject.transform.position = new Vector3(
            waypoint.transform.position.x,
            waypoint.transform.position.y,
            transform.position.z);
    }
Example #12
0
        public void Activate(WaypointController waypointController)
        {
            _selectedWaypoint = waypointController;

            var waypointPosition = waypointController.transform.localPosition;

            xValueInputField.text = waypointPosition.x.ToString();
            yValueInputField.text = waypointPosition.y.ToString();
            zValueInputField.text = waypointPosition.z.ToString();
        }
Example #13
0
        private void OnDeleteButtonClick()
        {
            if (_selectedWaypoint == null)
            {
                return;
            }

            WaypointManager.Instance.DeleteWaypoint(_selectedWaypoint.id);
            _selectedWaypoint = null;
        }
    void Awake()
    {
        Instance           = this;
        _waypointMarkers   = new List <WaypointMarker>();
        _lineRendererRoute = GetComponent <LineRenderer>();
        _lineRendererRobot = transform.GetChild(0).GetComponent <LineRenderer>();

        foreach (ThresholdZone zone in _thresholdZones)
        {
            _thresholdZoneDict.Add(zone.ThresholdZoneType, zone);
        }
    }
Example #15
0
    public WaypointController GetNext(int current)
    {
        int index = (current + 1);

        if (index >= waypoints.Count)
        {
            return(null);
        }
        WaypointController next = waypoints[current + 1];

        return(next);
    }
Example #16
0
 private void EnterRoom(string name)
 {
     for (var i = 0; i < room.waypoints.waypoints.Count; i++)
     {
         var new_waypoint = room.waypoints.waypoints[i];
         if (new_waypoint.new_room.name == name)
         {
             waypoint = new_waypoint;
             break;
         }
     }
 }
Example #17
0
    void Awake()
    {
        healthController   = GetComponent <HealthController>();
        waypointController = GetComponent <WaypointController>();
        ragdollController  = GetComponent <RagdollController>();

        player       = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();
        targetFinder = GetComponentInChildren <PlayerTargeter>();

        NMAgent     = GetComponent <NavMeshAgent>();
        animator    = GetComponent <Animator>();
        mineTrigger = GetComponent <SphereCollider>();
    }
Example #18
0
    public void MakeDecision(List <IEdge> outgoingEdges, Action <IBranchDecisionResult> answer)
    {
        List <WaypointController> controllers = new List <WaypointController>();
        var allWaypoints = RetrieveAllWaypointControllers();

        foreach (var edge in outgoingEdges)
        {
            controllers.Add(allWaypoints.First(x => x.waypoint.LifetimeId == edge.Target.LifetimeId));
        }

        WaypointController sourceController = allWaypoints.First(x => x.waypoint.LifetimeId == outgoingEdges.First().Source.LifetimeId);

        GameObject.FindObjectOfType <BranchingDecider>().Decide(answer, controllers, sourceController);
    }
    void instantiateControllers()
    {
        aiController       = GameObject.FindGameObjectWithTag("AIController").GetComponent <AIController>();
        waypointController = GameObject.FindGameObjectWithTag("WaypointController").GetComponent <WaypointController>();

        waypointController.createWaypoints(ammountOfWaypoints);
        aiController.createCars(ammountOfAi);

        guiController = GameObject.FindGameObjectWithTag("GUIController").GetComponent <GUIController>();

        inGameGuiController = GameObject.FindGameObjectWithTag("GUIController").GetComponent <InGameGUIController>();

        guiController.setProgram(ProgramObjectController.getProgram(), null);
    }
    // Start is called before the first frame update
    void Start()
    {
        _moveSpeed                  = Random.Range(moveSpeedRange.x, moveSpeedRange.y);
        _rotateSpeed                = Random.Range(rotateSpeedRange.x, rotateSpeedRange.y);
        _switchStatsRate            = Random.Range(switchStatsRate.x, switchStatsRate.y);
        _waypointController         = GameObject.Find("Waypoints").GetComponent <WaypointController>();
        _currentWaypointTargetIndex = 0;
        _rend = transform.GetChild(0).GetComponent <MeshRenderer>();
        _rend.material.color = Color.red;
        _rb = GetComponent <Rigidbody>();
        transform.localScale = transform.localScale * Random.Range(0.6f, 1.4f);

        InvokeRepeating("SwitchStats", 0, _switchStatsRate);
    }
Example #21
0
    void Start()
    {
        commandPanel       = GameObject.Find("CommandUI");
        waypointController = GameObject.Find("SquadController").GetComponent <WaypointController>();
        childLength        = commandPanel.transform.childCount;

        for (int i = 0; i < childLength; i++)
        {
            Transform currentChild = commandPanel.transform.GetChild(i);
            currentChildren.Add(currentChild);
        }

        SetChildrenStatus(false);
    }
    private void DefineWaypoint(ref WaypointController waypoint, int index)
    {
        // se o index for maior que 0, ele serĂ¡ igual ao seu valor subtraido de 1
        if (index < 0)
        {
            // Length = comprimento do Array
            index = waypoints.Length - 1;
        }
        // caso contrario, obrigatoriamente sera igual a 0
        else if (index == waypoints.Length)
        {
            index = 0;
        }

        // determinacao do index do waypoint dentro do Array
        waypoint = waypoints[index];
    }
Example #23
0
 void Start()
 {
     life            = 100;
     currentWayPoint = 0;
     target          = WaypointManager.instance.GetNext(currentWayPoint);
 }
Example #24
0
 public float minSpeed, maxSpeed;    //minSpeed - higher number but low speed(eg. 3), maxSpeed - lower number max speed (eg.1)
 // Use this for initialization
 void Start()
 {
     playerTransform          = GameObject.FindGameObjectWithTag("Player").transform;
     waypointControllerScript = GameObject.FindGameObjectWithTag("WaypointController").GetComponent <WaypointController>();
     closestWaypoint          = waypointControllerScript.FindClosestWaypoint(transform);
 }
Example #25
0
 void Start() => instance = this;
Example #26
0
 // Use this for initialization
 void Start()
 {
     objTransform       = this.transform;
     waypointController = GameObject.FindObjectOfType <WaypointController>();
     // readyForPanic = false;
 }
Example #27
0
 public void Deactivate()
 {
     _selectedWaypoint = null;
 }
Example #28
0
    public void Awake()
    {
        anim = GetComponentInChildren<Animator>();
        renderers = GetComponentsInChildren<Renderer>();

        targeting = FindObjectOfType<TowerTargeting>();
        targets = GetComponentsInChildren<TowerTarget>();
        myEffect = GetComponent<Effect>();

        wayPointController = GetComponentInChildren<WaypointController>();

        InitGem();

        for (int i = 0; i < targets.Length; i++)
        {
            targets[i].Init(this);
        }

        //get this towers waypoints
        if (wayPointController.transform.childCount > 0)
        {
            for (int i = 0; i <= wayPointController.transform.childCount - 1; i++)
            {
                wayPoints.Add(wayPointController.transform.GetChild(i));
            }
        }
        // always start by trying to cull
        StartCulling();
    }
Example #29
0
    private void Update()
    {
        TrackState();

        if (meow_counter < meow_delay)
        {
            meow_counter += Time.deltaTime;
        }
        else
        {
            var chance = Random.Range(0, 101);
            if (chance < 33)
            {
                audio_controller.PlaySound("Meow 1");
            }
            if (chance >= 33 && chance < 66)
            {
                audio_controller.PlaySound("Meow 2");
            }
            if (chance >= 66 && chance < 100)
            {
                audio_controller.PlaySound("Meow 3");
            }

            meow_delay   = Random.Range(8, 26);
            meow_counter = 0;
        }

        if (time >= 1)
        {
            state.Cycle(this);

            time = 0;
        }

        if (time_until_next_pet > 0)
        {
            time_until_next_pet -= Time.deltaTime;
        }

        time += Time.deltaTime;

        if ((this.emotionality == "Hungry" ||
             this.emotionality == "Hungry and Tired") &&
            bowl.meal_object.activeSelf == true &&
            is_eating == false &&
            is_sleeping == false)
        {
            if (room.name != "Kitchen")
            {
                EnterRoom("Kitchen");
                Walk();

                if (Vector2.Distance(transform.position, waypoint.transform.position) < 0.2f)
                {
                    if (waypoint.type == WaypointType.Origin)
                    {
                        ChangeToRoom(waypoint.new_room);
                    }
                }

                return;
            }

            if (Vector2.Distance(transform.position, bowl.transform.position) < 0.1f)
            {
                state = new CatEating(animator, animations["Eating"]);
                Invoke("StopEating", bowl.meal.time_to_devour);

                model.ToggleCatEatingSounds(true);
                is_eating = true;
            }
            else
            {
                state = new CatWalking(animator, animations["Walking"]);
            }

            WalkTo(bowl.transform);
            return;
        }

        if (is_eating)
        {
            return;
        }

        if (this.emotionality == "Tired" &&
            room.IsLightsOn() == false &&
            is_sleeping == false &&
            Vector2.Distance(transform.position, waypoint.transform.position) < 0.2f)
        {
            state = new CatSleeping(animator, animations["Sleeping"]);

            StartCoroutine(notification_display.RemoveNotification(Mood.Tired, 0));
            notification_display.SendNotification(Mood.Sleeping);

            is_sleeping = true;

            Invoke("StopSleeping", 120);
        }

        if (is_sleeping)
        {
            return;
        }

        if (this.emotionality != "Tired" &&
            this.emotionality != "Hungry and Tired" &&
            this.emotionality != "Hungry" &&
            this.happiness < 40)
        {
            if (Vector2.Distance(transform.position, toy.transform.position) < 0.5f)
            {
                is_playing = true;

                model.ToggleCatPlayingSounds(true);
                state = new CatPlaying(animator, animations["Standing"]);
                notification_display.SendNotification(Mood.Playing);

                Invoke("StopPlaying", toy.time_to_play);
            }
            else
            {
                if (is_playing)
                {
                    StopPlaying();
                }
            }
        }

        if (is_playing)
        {
            return;
        }

        if (entering_new_room == false)
        {
            if (time_until_next_action <= 0)
            {
                time_until_next_action = UnityEngine.Random.Range(3, 8);
                waypoint = GetRandomWaypoint(false);
            }
            else
            {
                time_until_next_action -= Time.deltaTime;
            }
        }

        if (Vector2.Distance(transform.position, waypoint.transform.position) < 0.2f)
        {
            state = new CatStanding(animator, animations["Standing"]);

            if (entering_new_room == true)
            {
                entering_new_room = false;
            }

            if (waypoint.type == WaypointType.Origin)
            {
                ChangeToRoom(waypoint.new_room);
            }
        }
        else
        {
            state = new CatWalking(animator, animations["Walking"]);

            Walk();
        }
    }
 public void addWaypoint(WaypointController waypointController)
 {
     waypoints.Add(waypointController);
 }
 void Awake()
 {
     controller = (WaypointController)target;
 }
	void Awake()
	{
		instance = this;
	}
    public void Decide(Action <IBranchDecisionResult> answer, List <WaypointController> possibleTargetWaypoints, WaypointController sourceWaypoint)
    {
        AnswerCallBack = answer;

        foreach (var target in possibleTargetWaypoints)
        {
            GameObject arrow = Instantiate(ArrowPrefab, this.transform);
            arrow.GetComponent <Interactable>().OnClick.AddListener(() => ArrowClicked(target.waypoint));
            Arrows.Add(arrow);

            //This double-setting of the position allows to easily rotate the arrow towards its target
            //Since this code is called in an update method from somewhere, setting it twice shouldn't impact
            //The performance too much, since neither graphics are rendered, nor physics simulated during the update method
            arrow.transform.position = sourceWaypoint.transform.position;
            arrow.transform.LookAt(target.transform);
            arrow.transform.position = sourceWaypoint.transform.position + (target.transform.position - sourceWaypoint.transform.position).normalized * 0.8f + Vector3.up * 0.2f;
        }
    }