コード例 #1
0
    private void FindClosestObject()
    {
        lastClosestObject = closestObject;
        float closestDistance = float.MaxValue;

        foreach (ObjectMover moveable in availableObjects)
        {
            float currentDistance = Vector3.Magnitude(this.transform.position - moveable.GetTransform().position);

            if (currentDistance < closestDistance)
            {
                closestDistance = currentDistance;
                closestObject   = moveable;
            }
        }

        if (lastClosestObject != null && lastClosestObject != closestObject && !lastClosestObject.GetGrabbed())
        {
            lastClosestHighlighter.TurnHighlightOff();
        }

        if (!closestHighlighter.GetHighlightOn() || (!closestObject.GetGrabbed() && closestHighlighter.GetHighlightColor() != selectColor))
        {
            closestHighlighter.TurnHighlightOn(selectColor);
        }
    }
コード例 #2
0
    private void Start()
    {
        //init communcation channels
        textCommChannel     = CommunicationChannelFactory.Make2WayTextChannel() as TextCommunicationChannel;
        oneWayCommChannel   = CommunicationChannelFactory.MakeOneWayTextChannel() as OneWayTextCommunication;
        roomExitCommChannel = CommunicationChannelFactory.MakeRoomExitPathChannel() as RoomExitPathCommChannel;
        oneWayTimedComm     = CommunicationChannelFactory.MakeOneWayTimedChannel() as OneWayTimedCommChannel;
        stillnessTimedComm  = CommunicationChannelFactory.MakeTimedStillnessChannel() as StillnessTimedCommChannel;

        //init object mover
        objectMover = ObjectMover.CreateObjectMover();

        playerCurrentCoords = player.MazeCellCoords;

        //start out not in communcation
        aiCommState      = AICommunicationState.NotInCommuncation;
        aiAlignmentState = AIAlignmentState.Neutral;

        //initialize list of possible actions (for each state)
        InitializeActionLists();

        roomsRequestedIn = new Dictionary <IntVector2, bool>();

        rng = new System.Random();
    }
コード例 #3
0
    private void Start() {

        //init communcation channels 
        textCommChannel = CommunicationChannelFactory.Make2WayTextChannel() as TextCommunicationChannel;
        oneWayCommChannel = CommunicationChannelFactory.MakeOneWayTextChannel() as OneWayTextCommunication;
        roomExitCommChannel = CommunicationChannelFactory.MakeRoomExitPathChannel() as RoomExitPathCommChannel;
        oneWayTimedComm = CommunicationChannelFactory.MakeOneWayTimedChannel() as OneWayTimedCommChannel;
        stillnessTimedComm = CommunicationChannelFactory.MakeTimedStillnessChannel() as StillnessTimedCommChannel;

        //init object mover
        objectMover = ObjectMover.CreateObjectMover();

        playerCurrentCoords = player.MazeCellCoords;

        //start out not in communcation
        aiCommState = AICommunicationState.NotInCommuncation;
        aiAlignmentState = AIAlignmentState.Neutral;

        //initialize list of possible actions (for each state)
        InitializeActionLists();

        roomsRequestedIn = new Dictionary<IntVector2, bool>();

        rng = new System.Random();
    }
コード例 #4
0
ファイル: CloudController.cs プロジェクト: Mroxny/Cyber_Four
    void Start()
    {
        SpriteRenderer sr = GetComponent <SpriteRenderer>();
        ObjectMover    om = GetComponent <ObjectMover>();

        transform.position = new Vector2(Random.Range(35, 81), Random.Range(-10, 11));
        sr.sprite          = skins[Random.Range(0, skins.Count)];
        if (Random.Range(1, 6) == 1)
        {
            sr.flipX = true;
        }
        int randScale   = 0;
        int randWayBack = 0;

        if (Random.Range(1, 5) == 1)
        {
            randScale            = Random.Range(35, 41);
            transform.localScale = new Vector2(randScale, randScale);
            sr.sortingOrder      = 20;
            om.velocity          = Random.Range(5, 11);
            randWayBack          = Random.Range(110, 200);
            om.repeatAfter       = randWayBack;
            om.backPoints        = randWayBack;
        }
        else
        {
            randScale            = Random.Range(17, 21);
            transform.localScale = new Vector2(randScale, randScale);
            sr.sortingOrder      = -20;
            om.velocity          = Random.Range(1, 11);
            randWayBack          = Random.Range(110, 200);
            om.repeatAfter       = randWayBack;
            om.backPoints        = randWayBack;
        }
    }
コード例 #5
0
 public void setmovetarget()
 {
     if (Main.config.objectsMoveStep > 0f)
     {
         $"Target: {ObjectMover.findTarget()?.name ?? "null"}".onScreen();
     }
 }
コード例 #6
0
 public void SetValues(float range, float time, AnimationCurve curve, ObjectMover objectMover)
 {
     this.range       = range;
     this.time        = time;
     this.curve       = curve;
     this.objectMover = objectMover;
 }
コード例 #7
0
 void Start()
 {
     if (MovableObject != null)
     {
         MoverScript = MovableObject.GetComponent <ObjectMover>();
     }
 }
コード例 #8
0
    // Update is called once per frame
    void Update()
    {
        if (grabbedObject == null)
        {
            if (availableObjects.Count > 0)
            {
                FindClosestObject();
                //Debug.Log("Closest Object to Hand " + this.name + ": " + closestObject.GetGameObject().name);
            }
            else if (closestObject != null)
            {
                if (lastClosestObject != null && !lastClosestObject.GetGrabbed())
                {
                    lastClosestHighlighter.TurnHighlightOff();
                    lastClosestObject = null;
                }

                if (!closestObject.GetGrabbed())
                {
                    closestHighlighter.TurnHighlightOff();
                }
                closestObject = null;
            }
        }

        if (padClicked)
        {
            MoveCharacter();
        }
    }
コード例 #9
0
    private void Start()
    {
        mover     = GetComponent <ObjectMover>();
        animator  = GetComponentInChildren <Animator>();
        ccollider = GetComponentInChildren <Collider>();

        TimeManager.OnTimePassed += TimeManager_OnTimePassed;
    }
コード例 #10
0
ファイル: Enemy.cs プロジェクト: zelimirfodor/TestZelimir
    void Awake()
    {
        _animator    = GetComponent <Animator> ();
        _objectMover = GetComponentInParent <ObjectMover> ();

        _enemyLayer   = LayerMask.NameToLayer("Enemy");
        _stunnedLayer = LayerMask.NameToLayer("Stunned");
    }
コード例 #11
0
    void SpawnObject()
    {
        Quaternion  objectRotation     = Quaternion.Euler(0, (m_Direction == ObjectMover.Direction.Forward) ? 0 : 180, 0);
        GameObject  spawnedObject      = GameObject.Instantiate(m_ObjectPrefab, transform.position, objectRotation) as GameObject;
        ObjectMover spawnedObjectMover = spawnedObject.GetComponent <ObjectMover>();

        spawnedObjectMover.m_Direction = m_Direction;
    }
コード例 #12
0
    // Use this for initialization
    void Start()
    {
        this.NavPointFollower = GetComponentInChildren <ObjectMover> ();

        //setting agent
        this.agent = GetComponent <NavMeshAgent> ();

        this.waypoint = GameObject.FindWithTag("Player").transform;
    }
コード例 #13
0
    private void OnTriggerExit(Collider other)
    {
        ObjectMover moveableObject = other.GetComponent <ObjectMover>();

        if (moveableObject != null && moveableObject != grabbedObject)
        {
            availableObjects.Remove(moveableObject);
        }
    }
コード例 #14
0
    private void Start()
    {
        animator   = GetComponent <Animator>();
        Attributes = GetComponent <UnitAttributes>();
        Mover      = GetComponent <ObjectMover>();

        MaxHealth = gameObject.GetComponent <UnitAttributes>().GetAttributeValue(Attribute.MaxHealth);
        Health    = MaxHealth;
    }
コード例 #15
0
    private void Mover_OnChangeState(ObjectMover mover)
    {
        if (mover.IsMoving)
        {
            return;
        }

        animator.SetBool("Walk", false);
        ccollider.enabled    = true;
        mover.OnChangeState -= Mover_OnChangeState;
    }
コード例 #16
0
    private void Awake()
    {
        ani = GetComponent <Animator>();
        om  = gameObject.GetComponent(typeof(ObjectMover)) as ObjectMover;

        // Set random speed for this one object
        speed = Random.Range(minSpeed, maxSpeed);
        om.setSpeed(speed);

        nextFootPrint = footprintSpace;
    }
コード例 #17
0
    private void OnMoverStateChanged(ObjectMover mover)
    {
        if (mover.IsMoving)
        {
            return;
        }

        currentPatrolPointIndex++;
        currentPatrolPointIndex = currentPatrolPointIndex >= PatrolRoute.Length ? 0 : currentPatrolPointIndex;

        mover.Target = PatrolRoute[currentPatrolPointIndex];
    }
コード例 #18
0
    public void ChangeSpeed(float newSpeed)
    {
        for (int i = 0; i < indexSpawnedObjects.Count; i++)
        {
            int         index = indexSpawnedObjects[i];
            ObjectMover om    = createdObjects[index].GetComponent <ObjectMover>();

            if (om != null)
            {
                om.gameSpeed = newSpeed;
            }
        }
    }
コード例 #19
0
        public void moveobject(float dx, float dy, float dz)
        {
            if (Main.config.objectsMoveStep == 0f)
            {
                return;
            }

            var offset = new Vector3(dx, dy, dz) * Main.config.objectsMoveStep;

            if (!ObjectMover.moveObject(offset))
            {
                "No target is selected!".onScreen();
            }
        }
コード例 #20
0
    // events

    private void OnTriggerEnter(Collider other)
    {
        ObjectMover moveableObject = other.GetComponent <ObjectMover>();

        if (moveableObject != null && !availableObjects.Contains(moveableObject))
        {
            //Debug.Log("Adding object " + other.name + " to Hand " + this.name + " available objects.");
            availableObjects.Add(moveableObject);
        }
        else
        {
            //Debug.Log("No moveable object found.");
        }
    }
コード例 #21
0
ファイル: MovingPlatform.cs プロジェクト: kyanicu/Endpoint
    private void Awake()
    {
        col = GetComponent <Collider2D>();

        if (!(mover = GetComponent <ObjectMover>()))
        {
            mover = gameObject.AddComponent <ObjectMover>();
        }

        col.isTrigger   = false;
        mover.stopOnHit = false;

        center = transform.position + (Vector3)(direction * speed * change) / 2;
    }
コード例 #22
0
ファイル: MovingPlatform.cs プロジェクト: kyanicu/Endpoint
    private void Reset()
    {
        //Const Values

        col = GetComponent <Collider2D>();

        if (!(mover = GetComponent <ObjectMover>()))
        {
            mover = gameObject.AddComponent <ObjectMover>();
        }

        col.isTrigger   = false;
        mover.stopOnHit = false;
    }
コード例 #23
0
    private void Awake()
    {
        ani = GetComponent <Animator>();
        gc  = FindObjectOfType <GeneratorController>();
        om  = gameObject.GetComponent(typeof(ObjectMover)) as ObjectMover;
        om.setSpeed(speed);
        sound = FindObjectOfType <SoundController>();

        if (!Settings.getMusic())
        {
            //disable the music
            music.SetFloat("musicVol", -80f);
        }
        nextFootPrint = footprintSpace;
    }
コード例 #24
0
    private void Awake()
    {
        mover = GetComponent <ObjectMover>();
        if (PatrolRoute != null && PatrolRoute.Length > 0)
        {
            mover.OnChangeState += OnMoverStateChanged;
            mover.Target         = PatrolRoute[0];
        }

        player = GameObject.FindGameObjectWithTag("Player").transform;
        if (!player)
        {
            this.enabled = false;
        }
    }
コード例 #25
0
    private void Awake()
    {
        if (!(capCol = GetComponent <CapsuleCollider2D>()))
        {
            capCol = gameObject.AddComponent <CapsuleCollider2D>();
        }

        if (!(mover = GetComponent <ObjectMover>()))
        {
            mover = gameObject.AddComponent <ObjectMover>();
        }


        capCol.isTrigger = true;
    }
コード例 #26
0
    private void Reset()
    {
        //Const Values

        if (!(capCol = GetComponent <CapsuleCollider2D>()))
        {
            capCol = gameObject.AddComponent <CapsuleCollider2D>();
        }
        if (!(mover = GetComponent <ObjectMover>()))
        {
            mover = gameObject.AddComponent <ObjectMover>();
        }

        capCol.isTrigger = true;
    }
コード例 #27
0
 public void Release()
 {
     if (grabbedObject)
     {
         Debug.Log("Hand: " + this.name + " has called Release()");
         HighlightController grabbedHighlighter = grabbedObject.GetGameObject().GetComponent <HighlightController>();
         grabbedHighlighter.TurnHighlightOff();
         grabbedObject.Release();
         grabbedObject = null;
     }
     else
     {
         return;
     }
 }
コード例 #28
0
    //This region contains code for ending the game.
    //There are currently 3 types of endings the AI can initiate.
    #region

    //start off the end of the game. ending changes depending on ai state.
    private void FlyoverMonologueEnding()
    {
        Debug.LogError("about to close doors in cell monologueending");
        maze.CloseDoorsInCell(playerCurrentCoords);
        player.PermanentlyFreezePlayer();
        SendMessageToPlayer(GameLinesTextGetter.GetEndingMonologue(AIAlignmentState.Neutral), oneWayCommChannel);

        ObjectMover objMoverTwo = ObjectMover.CreateObjectMover();

        objectMover.MoveObjectStraightLine(player.gameObject, new Vector3(0, 2.0f, 0), 1f);

        Action <GameObject> setGameOverFlag = (obj => gameOver = true);

        objMoverTwo.SpinObject(player.gameObject, 600f, 30f, setGameOverFlag);

        maze.StartRandomizingMaze(2.0f);
    }
コード例 #29
0
    private void ConvertDataToRoom(RoomData roomData)
    {
        ObjectMover.hasPlaced = false;

        GameObject room = roomPrefabs.Where(roomPrefab =>
                                            roomPrefab.GetComponent <ObjectScript>().objectNum == roomData.objectNum).Select(roomPrefab =>
                                                                                                                             Instantiate(roomPrefab, new Vector3(roomData.x, roomData.y, 0), Quaternion.identity)).FirstOrDefault();

        ObjectMover  om        = room.GetComponent <ObjectMover>();
        ObjectScript os        = room.GetComponent <ObjectScript>();
        RoomStats    roomStats = room.GetComponent <RoomStats>();

        os.ResetData();

        om.TurnOffBeingDragged();
        os.preplacedRoom   = roomData.isPrePlaced;
        roomStats.usedRoom = roomData.usedRoom;
        roomStats.ChangeRoomLevel(roomData.roomLevel); // starts at 1 so only change if greater than 1
        roomStats.currentCrew = roomData.crew;
        if (!roomStats.flatOutput)
        {
            StartCoroutine(UpdateRoomStat(roomStats, roomData));
        }

        room.transform.GetChild(0).transform.Rotate(0, 0, -90 * (roomData.rotation - 1));

        if ((os.shapeType != 0 || os.shapeType != 1 || os.shapeType != 3) && (os.rotAdjust == 1 || os.rotAdjust == 3) && (roomData.rotation == 2 || roomData.rotation == 4))
        {
            room.transform.GetChild(0).transform.position += os.rotAdjustVal;
        }
        else if ((os.shapeType != 0 || os.shapeType != 1 || os.shapeType != 3) && (os.rotAdjust == 2 || os.rotAdjust == 4) && (roomData.rotation == 1 || roomData.rotation == 3))
        {
            room.transform.GetChild(0).transform.position -= os.rotAdjustVal;
        }

        os.rotAdjust = roomData.rotation;
        om.UpdateMouseBounds(os.boundsDown, os.boundsUp, os.boundsLeft, os.boundsRight);

        ObjectMover.hasPlaced = true;

        om.enabled = false;

        room.transform.GetChild(0).gameObject.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 1);

        StartCoroutine(UpdateSpotChecker(room, roomData.isPrePlaced, roomData.rotation));
    }
コード例 #30
0
    void ChangeSpeed()
    {
        if (!changeSpeed)
        {
            return;
        }

        for (int i = 0; i < createdObjects.Count; i++)
        {
            ObjectMover om = createdObjects[i].GetComponent <ObjectMover>();

            if (om == null)
            {
                return;
            }
            om.speed = speed;
        }
    }
コード例 #31
0
    internal void HoverCard(CardObject card, bool isHovered)
    {
        if (card == selectedCard)
        {
            return;
        }

        ObjectMover mover = card.GetComponent <ObjectMover>();

        if (!isHovered)
        {
            mover.ResetPosition();
        }
        else
        {
            mover.MoveToOffset(hoverOffset);
        }
    }
コード例 #32
0
ファイル: Player.cs プロジェクト: spilist/spaceroad
 public void processCollision(ObjectMover mover, Collision collision)
 {
     float damageStandard = collision.relativeVelocity.magnitude;
     EnergyManager.em.loseEnergy(damageStandard);
 }